2

Working on a site that has a bunch of different locales, I'm bumping into the following issue:

On an entry in locale X, I have an image that is displayed with a transform applied to it. However, getUrl()on the asset returns the following url: /benl/cpresources/404?x=6obDEISgU.

But, when I add that exact same image to an entry in the site's main locale and view it on the front-end, the transform is generated and the image is displayed correctly.

When I then go back to the other entry in locale X (that has that same image), it uses the generated transform (from the entry in the main locale) and the page works.

So it looks like the transformed images can't be generated on the entry in the none-standard locale.

Some settings/parameters:

  • locales live in their own subfolder as per https://craftcms.com/docs/localization-guide
  • basePath is set to the main site's document root, without the locale folder
  • baseUrl is set the main site url, without the locale segment

Any pointers as to how to troubleshoot and/or fix this would be appreciate :)

2

Ran into a similar problem on a past project, it could be your .htaccess acting up and redirecting the call to cpresources to /benl/cpresources as opposed to /cpresources/.

If you look at your console on the page that the image is broken - you might be getting a 404 error. If that is the case...

Adding this rewrite rule helped my project and may help yours as well.

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^cpresources/transforms/(.*)  /cpresources/transforms/$1 [L,R,NE,QSA]

Add this rule to your .htaccess in your /benl/ directory before the default index.php rewrite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.