← Design & Development Blog
January 7, 2015

Get the URL of an image using Get The Image plugin

If you use Hybrid Core or any of the themes on Theme Hybrid, or use Get the Image as a standalone plugin, you’re probably familiar with how the function works, and thankful that Justin built it. I recently needed to get just the url of the image to add as a background via css. Here’s how to do it:

[php]
<?php $image = get_the_image( array( ‘size’ => ‘full’, ‘format’ => ‘array’ ) ); ?>
<?php if ( !empty( $image ) ) $url = $image[‘src’]; ?>

<li style="background-image: url(<?php echo $url; ?>)">

</li>
[/php]