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]

2 thoughts on “Get the URL of an image using Get The Image plugin

Leave a Reply

Your email address will not be published. Required fields are marked *

Ready for a refreshing experience on your next website design?