Get featured image on Blog Index

if you are referring to the ‘page for posts’, then try (only relevant section of your code shown): if (is_home() && get_option(‘page_for_posts’) ) { $img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option(‘page_for_posts’)),’full’); $featured_image = $img[0]; } else {

Post thumbnail alt title

It is necessary to set an alt value for all of your images, in case a browser can not load the image or the visitor is using screen reader. You have two options. Either use the featured image’s caption (which can some times be blank) or use the post’s title as alt. You can get … Read more

Delete original image – keep thumbnail?

add_filter( ‘wp_generate_attachment_metadata’, ‘delete_fullsize_image’ ); function delete_fullsize_image( $metadata ) { $upload_dir = wp_upload_dir(); $full_image_path = trailingslashit( $upload_dir[‘basedir’] ) . $metadata[‘file’]; $deleted = unlink( $full_image_path ); return $metadata; }

Display thumbnail only if requested size exists

Assuming the question is about wp_get_attachment_image_src. It could be also about wp_get_attachment_link, but, although related, this analysis doesn’t includes it. Got aware of this issue answering this question: How can I view all WP generated thumbnails in Media Manager?. Refer to it to see a working code regarding the issue on this Question. And it … Read more

How do I regenerate thumbnails?

i have only had to do this on a couple of occasions, but each time i have used this regenerate thumbnails plugin on each occasion with a 100% success rate, however (as you will expect it did take quite a bit of time as i had over a 1000 images that it had to wade … Read more

How to add post featured image to RSS item tag?

You could do it by adding an action to the hook ‘rss2_item’ like so: add_action(‘rss2_item’, function(){ global $post; $output=””; $thumbnail_ID = get_post_thumbnail_id( $post->ID ); $thumbnail = wp_get_attachment_image_src($thumbnail_ID, ‘thumbnail’); $output .= ‘<post-thumbnail>’; $output .= ‘<url>’. $thumbnail[0] .'</url>’; $output .= ‘<width>’. $thumbnail[1] .'</width>’; $output .= ‘<height>’. $thumbnail[2] .'</height>’; $output .= ‘</post-thumbnail>’; echo $output; });