In particular this line:

$uri = str_replace($default_stream_wrapper->getDirectoryPath(), '', $streamwrapper . $image_url);

Usually $default_stream_wrapper->getDirectoryPath() returns sites/default/files but in my case the public files directory was simply in a top-level "files" directory, so that every instance of the string "files" was removed from the filepath. In general it's not great to remove arbitrary things from the filepath.

CommentFileSizeAuthor
#2 3034728-2.patch2.14 KBtstoeckler

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Status: Active » Needs review
StatusFileSize
new2.14 KB

In attempting to fix this issue, I couldn't really understand the purpose of the surrounding code. Here's a patch that seemed to work for me, and also simplify the code. But not sure if there are situations where this breaks things in particular when using a non-local stream.

I would greatly welcome your input on this! ;-)

jan.stoeckler’s picture

Status: Needs review » Fixed

Works nicely, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.