OFFLINE-GmbH / oc-responsive-images-plugin

Adds reponsive images capabilities to October CMS
MIT License
45 stars 26 forks source link

Plugin doesn't work with project-level symlinks #89

Open boyardnicolas opened 2 years ago

boyardnicolas commented 2 years ago

On our staging server all the images detected from the DomManipulator are treated as not local pictures. In ResponsiveImage class, the FileHelper::isLocalPath always returns false since the path of the picture sent as argument is the symlinked path (i.e /mnt/storage/staging/website/shared/storage/app/media/Icons/icon-copy-2@2x.png), but in that method the base path used to compare is the real path of the project (i.e /mnt/storage/staging/website/releases/20220128095408/storage/app/media/Icons/icon-copy-2@2x.png). So for every project if you want to have zero downtime deployment using symlinked folders, you can't use this plugin as is.

Not sure where this issue should be tackled, plugin side, october side or laravel side.

If I remove that "isLocalPath" check from ResponsiveImage class the pictures are generated, the middleware also alter the html output, but it outputs the absolute path of the picture, using the symlinks (not real path) (https://website.domain/mnt/storage/staging/website/shared/storage/temp/public/d82/bd8/184shutterstock_1537552817__400.jpg)

Any idea on how to solve this issue in a clean way?

boyardnicolas commented 2 years ago

Hello, thanks for the heads-up, I've already tried this (i.e FileHelper::isLocalPath($this->path, false)) but it doesn't work in my case, the pictures are generated but incorrectly linked ( https://domain.com/mnt/storage/staging/website/shared/storage/temp/public/164/cbf/0468__1920.jpeg instead of https://domain.com/storage/temp/public...).

In my case I have two levels of symlinks, current release served by NGINX from /mnt/storage/staging/website/current, which is a symlink to /mnt/storage/staging/website/releases/{latest_release}, this seems to be solved by your solution. But then inside the project, the "storage" folder is also symlinked to a shared directory so that medias uploaded from back-office, framework and cms cache are kept across versions.

No time to dig further into that issue I'm afraid...