Thumbnails with external images

Short Version

thumb() doesn’t appear to work with external images. Is this intentional, or something to do with my PHP or Kirby setup?

Long Version

I am running a portfolio site with Kirby. As part of this, I am returning the thumbnail url of a Vimeo video using this code:

    $hash = unserialize(file_get_contents("".$item->videoID().".php"));
    $img = $hash[0]['thumbnail_large'] ?>

<img src="<?php echo $img ?>" class="img-responsive" />

However, when attempting to pass the $img variable to thumb(), Kirby returns nothing - no error code, no <img> tag, nothing.

To test this, I have also attempted passing a static external URL to thumb():

<?php $test = '' ?>
<?php echo thumb($test, array('width' => 400))->url(); ?>

With the same result: nothing, no error, no code.


thumb() Requires an Image Object

Looking through the Kirby Cheat Sheet, the one-line description of thumb() states:

thumb($image, $params = array())

Creates a thumbnail for a given image object

Is the possible problem that I am passing a URL, a string, rather than an image object? If so, is it possible to transform that string into an image object?

thumb() Cannot work with external URLs

Something about the way either the thumb() function is written, or how Kirby or PHP is configured is preventing the processing of external URLs in the manner.

You probably have to save the image locally, then use thumb().
Also, I think retrieving an external image every time would be a lot slower.

Same problem here :frowning:

As @Malvese wrote, it doesn’t make much sense to download the external image each time. You can download it programmatically once and then create thumbs.