I've started using this module for local development, and it's awesome! However, I've run into an issue. Images on my site with relative links like <img src="/sites/default/files/hw_jul_horg_sh_jul22.jpg"> are not being downloaded. All those with absolute links are. Any ideas? Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SeeWatson’s picture

Never mind. I realized this is because hard-linked images created in WYSIWYG text fields are not file objects and therefore do not go through file processing, which is the process by which this module copies them. I'll now be looking into either a text filter that will dynamically make them objects or will be using rsync or another such process.

tobiasb’s picture

Issue summary: View changes
greggles’s picture

@tobiasb do you have this problem as well?

@SeeWatson - my sense is that the module should work for files that are not "managed" files too. Basically it should work for any file, I think.

SeeWatson’s picture

Title: Images with Relative Links Not Being Downloaded » Non Drupal "Managed" Images Not Downloading

I completely agree @greggles. That's what I thought it did at first.

The only ways I can think of to do that would be some kind of text filter that would catch href="" and download the associated file or a theme hook of some kind that does similar, but I'm still relatively young into module development.

tobiasb’s picture

@greggles

Yes, in my case the path is <img alt="FOO" src="/sites/foo/files/FOO.png">.

danyg’s picture

I've created a patch which handles the unmanaged files within body (and in any other long text) fields.

With this patch, first of all, you have to set the watched fields on the stage file proxy's admin page.

Then, I've implemented a hook_preprocess_node which checks if the enabled fields are available in current node, checks the generated markups for images which are not acting with fully qualified URLs (like /sites/default/files), checks if those files already exist in local file system and if not, pulls the file from its origin.

I hope it helps. Please, if you have time, check and review it.

danyg’s picture

I'm revoking my previous patch since it contained a PHP7 supported array definition. Here is the fixed one.

danyg’s picture

danyg’s picture

Version: 7.x-1.7 » 7.x-1.9

Works with latest stable, so I updated the version.

smustgrave’s picture

Status: Needs review » Closed (outdated)

As there hasn't been movement on this in years going to close out as D7 support is being dropped. Will keep an eye out for security issues but active support is a no go.