How to get the URL of a each custom image size of a featured image

So, I finally noticed that what I was doing, was returning an array, and that I needed the [0] of that array. The code is on the ugly side, but it works. <?php $thumb_id = get_post_thumbnail_id(); $small_screen = wp_get_attachment_image_src($thumb_id,’small-screen’, true); $medium_screen = wp_get_attachment_image_src($thumb_id,’medium-screen’, true); $large_screen = wp_get_attachment_image_src($thumb_id,’large-screen’, true); $extra_large_screen = wp_get_attachment_image_src($thumb_id,’extra-large-screen’, true); ?> – <div … Read more

Set Featured Image Based on Custom Field

global $wpdb; $children = get_posts(‘post_type=event&numberposts=1’); foreach ($children as $child) { $origParentID = get_post_meta($child->ID, ‘mainpictureid’, true); $parsed_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), ‘http://localhost/wp-content/uploads/2015/08/’.$origParentID.’.jpg’ ); $attachment = $wpdb->get_col( $wpdb->prepare( “SELECT ID FROM {$wpdb->prefix}posts WHERE guid RLIKE %s;”, $parsed_url[1] ) ); set_post_thumbnail( $child->ID, $attachment[0]); }

add class to background image

I have added the style “background-position: center center;” and it work perfectly! So the new code will look like this: <?php global $post; $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, ” ); ?> <div class=”mainblogwrapper” style=”background-image: url(<?php echo $src[0]; ?> ) !important; background-attachment : fixed;background-position: center center;”>

Featured images not showing up

Finally found the issue: I was using a filter in my site specific plugin to remove image attributes. Somehow it also deleted the full image URL. add_filter( ‘post_thumbnail_html’, ‘remove_img_attributes’, 10 ); Removing that filter solved the issue.