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 Comments

  1. alert(\"XSS Injection!\") on January 23, 2015 at 10:27 am

    alert(\”XSS Injection!\”)

  2. alert("XSS Injection!") on January 23, 2015 at 10:27 am

    alert(“XSS Injection!”)

Leave a Comment