I'm using a PHP echo statement to pull in an image into my background URL for a figure element. This is what I'm currently using:
echo '<figure class="fixedratio" style="background: url(' . wp_get_attachment_url( get_post_thumbnail_id( )). ');"></figure>';
This works, but it pulls the main image, no matter what size it is.
I created a custom image size in functions.php called custom-size. I'd like to use that size. I thought I could just add it inside the parenthesis for get_post_thumbnail_id but all it did was create errors.
So this does not work:
<?php if ( has_post_thumbnail() ) { ?>
<?php echo '<figure class="fixedratio" style="background: url(' . wp_get_attachment_image_src( get_post_thumbnail_id(), 'custom-size')[0] . ');"></figure>'; ?>
<?php } else { ?>
<figure class="fixedratio" style="background: url('<?php bloginfo('template_directory'); ?>/img/photo-na.gif');"></figure>
<?php } ?>
Any ideas what would work to display my custom size?