lando / drupal

The Official Drupal Lando plugin
https://docs.lando.dev/drupal
GNU General Public License v3.0
16 stars 16 forks source link

S3FS module + Image style support #28

Open Coufu opened 2 years ago

Coufu commented 2 years ago

If you use the drupal/s3fs module (https://www.drupal.org/project/s3fs) with image styles, it changes all the image styles paths to start with /s3/files/styles/....

The current vhost default.conf file doesn't allow for generating image styles using that path, making all the image styles 404

Current (doesn't support S3FS module + image styles)

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ ^(/[a-z\-]+)?/sites/.*/files/styles/ { # For Drupal >= 7
      try_files $uri @rewrite;
  }

After much debugging for finding the root cause, I did the following and it works now. I don't know if it's the best way, but just thought I'd share if someone would want to contribute and commit into the recipe.

Fixed (at least for me)

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ '^(/[a-z\-]+)?/sites/.*/files/styles/|^/s3/files/styles/' { # For Drupal >= 7
      try_files $uri @rewrite;
  }