Hello. First let me say that I love this module! Thank you so much for creating it!

For my website I have the option checked which always makes a local copy of remote images. It works great. But I noticed one pretty big problem though and I was wondering if it's intentionally written this way or if it was an oversight.

Let's say you run the site goo.com and you create an article with a link to a remote image on foo.com and then later on someone at foo.com deletes that image or the site goes away or foo.com is temporarily inaccessible, etc etc. What happens on goo.com is that the image comes up as a broken/missing image.

(Technically speaking it doesn't show up as a broken/missing image until/unless you clear the drupal cache. In case you want to reproduce this.)

It seems to me that one of the points in making a local copy of the remote image is that your site goo.com doesn't have to suffer with broken/missing images even if the person at foo.com deletes that image.

So, I guess I'm wondering if this is an intentional feature or just an oversight that maybe has a quick and easy fix?

Comments

helloadorable’s picture

Title: Remote img goes missing later on causing local copy to not appear. Bug or Feature? » If remote img goes missing later, local copy does not come up. Bug or Feature?
quicksketch’s picture

Image Resize Filter was not made to prevent broken images. The downloading of remote images was intended to prevent hot linking and speed up requests by reducing DNS lookups. As it is, literally all images created by Image Resize Filter are always considered to be temporary. During updates Image Resize Filter has in the past deleted all the resized images and let them regenerate as needed. I don't think this will be a common situation that such an update is needed, but Image Resize Filter was not meant to provide permanent versions of remote images.

helloadorable’s picture

Ah. OK. Good to know. Makes sense. Thanks for the response!

I don't suppose you can suggest a code change I can make that will make it pull up the locally stored image if the remote one goes away?

Or if you happen to know if it would be very difficult to make such a code change?

I don't mind diving into the code and trying to figure out how to make this change... unless you happen to know it would be significantly difficult to change it to make it behave the way I'm describing...

quicksketch’s picture

It would be slightly difficult to do what you're describing, because the file name for remote images is an md5 hash of the actual file *contents*. If the remote file goes missing, Image Resize Filter can no longer calculate the local file name. Of course this could be changed to just md5 the URL, though this mean that "stale" images might be served by Image Resize Filter if the remote image changes (but maintains the same height/width). So it's possible to do what you're describing, though I don't think it can be an officially supported piece of functionality, since it would mean that local copies of images are no longer considered "temporary" and could no longer be deleted as needed on clean up routines.

helloadorable’s picture

That's a very helpful tip in the right direction! Thanks for the explanation and for pointing out the caveats. Much appreciated.

Fabianx’s picture

Hi,

I have just used image filter for importing big images from a legacy site.

I think an "official way" could be to store the images in a imagefield that accompanies the node.

(In my case I got a field_image in all content types, which makes this very easy)

Or as file attachments (if allowed).

This way they can be deleted, but are of a persistent nature, but don't need to be re-downloaded all the time.

I think this would then also work out happily together with insert. Note to original poster: filefield_sources already also provides the possibility to use remote images, but not automatically.

But perhaps this is a new filter module - similar in function to image resize filter (and using same reg exp).

At least this is the user friendliest way I can imagine for handling remote images:

Copy & Paste Image into Article, Save Node,

External Images are detected, downloaded and added as Files to the node, image path is changed to point to local file, original URL is saved in some metadata. Andimage resize filter is from now on detecting the local file.

The more I think about it, this could be done in another filter running before image_resize_filter called local_image_download or the like. Then image_resize_filter would not need to change ...

Just my thoughts on the issue.

Best Wishes,

Fabian (LionsAd)

quicksketch’s picture

I think an "official way" could be to store the images in a imagefield that accompanies the node.

If you can train your users to copy remote files locally first, you can use FileField Sources to pull in images from URLs directly.

Any "automatic" downloading and associating remote images with a FileField in the node is going to be outside the scope of this project.