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 $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>

2 Comments


alert(\”XSS Injection!\”)

Reply

alert(“XSS Injection!”)

Reply

Leave a Reply

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

Tell us about your project.

We'd love to hear what you're working on.

Work with us

Hi. We are Spigot. Telemarketers pronounce it Spy-got.

We are a Park City, Utah based web design shop that excels at building custom websites powered by WordPress and WooCommerce. We love content - content strategy, content curation, content soup...????Have a look around the site. As you browse you'll find useful navigation links in the sidebar on the left. We hope you find them useful anyway... Please let us know what you think, shoot us a message here.