Thumbnail's absolute URL

Permalink
Hi all,

I'm currently using:
$ih = Loader::helper('image');
 $img = $page->getAttribute('thumbnail'); 
 $thumb = $ih->getThumbnail($img, 300, 9999, false);
  $thumb->src;


To get the relative path to the thumbnail.

I'm wondering if it's possible to get the URL to the thumbnail instead.

So instead of /path/to/thumbail.jpg, i'm looking forhttp://www.example.com/path/to/thumbnail.jpg...

Thanks!

 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi stangn99,

Is there a specific reason for why you want the absolute URL?

The getURL() method can be used on the file object retrieved by $c->getAttribute('thumbnail') to get an absolute URL. This is the original file image though, not the thumbnail, so I am not sure if that is useful to you.

I don't think you can get an absolute path using the object returned with getThumbnail(). If you look at the method itself, src is $src = REL_DIR_FILES_CACHE . '/' . $filename;.
http://www.concrete5.org/api/source-class-Concrete.Core.Legacy.Imag...
http://www.concrete5.org/api/class-Concrete.Core.Legacy.ImageHelper...

$imageHelper = Core::make('helper/image');
$imageObject = $c->getAttribute('thumbnail');
$thumbnail = $imageHelper->getThumbnail($imageObject, 300, 9999, false);
// relative path to generated thumbnail
// Example:
// /concrete5/application/files/cache/9ebbeb4443a92f11db26aafdae783444.jpg
$thumbnail->src;
// absolute path to original image
// Example:
//http://localhost/concrete5/application/files/6114/3907/6528/cupcake...
$imageObject->getURL();
stangn99 replied on at Permalink Reply
MrKDilkington,

Thank you very much.

$imageObject->getURL(); did the trick!