Tag Info

Hot answers tagged

8

You can use the wp_generate_attachment_metadata filter: function wpse_183835_to_jpeg( $meta, $post_id ) { $sizes_to_convert = array( 'thumbnail', ); $path = dirname( get_attached_file( $post_id ) ); foreach ( $sizes_to_convert as $size ) { if ( ! empty( $meta['sizes'][ $size ] ) ) { $data = $meta['sizes'][ $size ...


2

I believe you're using the wrong function. get_the_time() doesn't actually return the current time but instead the time of when the post was published. Maybe what you're looking to use is date( 'H' ).


2

The correct core function should be current_time() Untested, but your code ought to look something like: if (current_time('H') >= 8 && current_time('H') < 20)


1

I've had the same problem and found it was due to the upload file size set for the server (in my case 2mb). There is another setting which escapes me at this point, but is basically a limit on the amount of space that can be used to process uploaded images...which WordPress does when it re-sizes the images on upload. Unfortunately, unless you have root ...


1

Assuming we are viewing some king of single - post, page, custom post type etc. <?php $imgs_meta = get_post_meta( get_the_ID(), 'AP_post_image', true ); if ( '' != $imgs_meta ) { $imgs = explode( ',', $imgs_meta ); foreach ( $imgs as $src ) printf( '<img src="%s" />', esc_url( $src ) ); }


1

Lets start with your first code. If you add texts, captions etc. a shortcode will be generated: [caption] The function img_caption_shortcode() in wp-content/media.php is responsible to execute the shortcode. But this shortcode is only produced, when you use captions. Otherwise, it will be simply inserted the <a>- and <img>-Tag. who decides, what ...


1

There's no native function, but the RICG Responsive Images plugin will add a srcset attribute with the available image sizes. Srcset (along with the <picture> element), is steadily gaining browser support - it doesn't need any javascript and it's up to the browser to decide which is the correct image to load. The attribute is added for posts where ...


1

you may use <?php the_post_thumbnail();?> to display the image where you wish. If you still have any problem then please share the code you are using



Only top voted, non community-wiki answers of a minimum length are eligible