Remote image resizing

Silverstripe Version:
4.10
Question:
Is there any way to use the resize / crop template functions o remote images? I have a data object which stores a reference to a remote image and I would like to be able to resize and/or crop it using the familiar Image.Fill(200,200) methods.

Thanks in advance

What do you mean with “remote image”? An Image that is hosted on another domain that does not belong to you or an image that is e.g. stored in S3?

To manipulate the image you need to download it somehow to your server and store it in an File or Image DataObject. This could be done on-the-fly, but be sure you have proper caching.

If it’s an image stored in another website it might be possible to manipulate the included image with CSS.

Be aware: it might not be legal to include “foreign remote” images in your website. Some companies are really allergic to this topic and send you expensive letters.

The S3 module should make it possible to manipulate on the fly, although I’m not really an expert there

I’m importing images from a Behance portfolio from my client so I shouldn’t be “ilegal” to include them. For the time being I’m storing the URLs in the database on a varchar field, but I would like to be able to resize said images on the template using the familiar tags provided by SilverStripe.

@ekersten any chance to import and sync the images, either via an API or manually? As that image manipulation methods manipulate the image on the server, you need it somehow on the server.

I’ve managed to import the projects as dataobjects and the images (called modules on the Behance API) as a separate dataobject with a has_many relationship between the project and the images. All I have today is the url of the image I want to display.

The path I’m taking right now is creating a method on the project image data object to check if a Silverstripe image was created and, if it’s not, create the file and return it so the template can call the resize / crop methods. I’ll update if I get this working.

I thought about doing it this way to avoid downloading / resizing unused images.

If you see another possible approach please let me know.

Thanks