Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image transformations on multi language sites #1853

Closed
hiasl opened this issue Jul 20, 2017 · 8 comments
Closed

Image transformations on multi language sites #1853

hiasl opened this issue Jul 20, 2017 · 8 comments
Labels

Comments

@hiasl
Copy link
Contributor

hiasl commented Jul 20, 2017

Description

Image transformations seem to have a problem on multilanguage sites. The source path of the image is not found on the first call wenn the img url is something like /en/cpresources/transforms/4?x=myZQ3ajZa

You will get the following exception:

HTTP 500 – Internal Server Error – yii\web\ServerErrorHttpException
No file exists at the given path.

If you manually remove the trailing /en and make /cpresources/transforms/4?x=myZQ3ajZa out of it, the image is going to resize and it will be saved correctly in its asset's file system path.

Additional information:

  • The assets volume base url is /userfiles/photos (yes against recommendation)
  • The assets volume file system path is userfiles/photos (yes against recommendation)
  • The multi language site's own base url is '/en/
  • The asset field, where the image is selected, has none of the advanced options set (Relate assets from a specific site?, Manage relations on a per-site basis).

Please note that the normal image usage works perfectly and also the rest of the multilanguage setup.

Steps to reproduce

  1. Use a Craft 3 Multilanguage Installation
  2. Prepare a working asset volume and place an image inside
  3. Place an image in the volume
  4. Select the image as asset in a entry
  5. Place a code like this the entries template:
    <img src="{{ image.getUrl({width: min(1400,image.width), height: min(788, image.height)}) }}" />
  6. Check the transformation URL (see description above)

Additional info

PHP version 7.1.6-1 ubuntu16.04.1+deb.sury.org+1
Database driver & version MySQL 5.7.18-0ubuntu0.16.04.1
Image driver & version Imagick 3.4.3, ImageMagick 6.8.9-9
Craft edition & version Craft Pro 3.0.0-beta.21
Yii version 2.0.12
Twig version 2.3.2
Guzzle version 6.2.1
Imagine version 0.7-dev

@brandonkelly
Copy link
Member

The assets volume file system path is userfiles/photos (yes against recommendation)

That is your issue. If you are going to be loading Craft from different directories, you can’t use a relative path. (Hence the recommendation for an absolute path.)

@hiasl
Copy link
Contributor Author

hiasl commented Jul 26, 2017

Can I refer do a DOCUMENT_ROOT or something like that?

I do not like the absolute path solution at all since this information is saved in the database and that makes transferring Craft from dev to prod and so on hard.

thanks

@andris-sevcenko
Copy link
Contributor

You can use a config file to override Volume settings.

@hiasl
Copy link
Contributor Author

hiasl commented Jul 26, 2017

Hey Andris, thanks a lot! that saved me :-)

@vasuhooda
Copy link

@hiasl @andris-sevcenko

Hey, I am facing the exact same problem, can you please tell me which volume settings did you change to fix the problem.

@andris-sevcenko
Copy link
Contributor

@vasuhooda the problem was caused using relative paths and was solved by using absolute paths.

@vasuhooda
Copy link

@andris-sevcenko

Thanks, that solved my issue.

I created an alias for assets path in the config file, and then used that to define path in the control panel '@assetBasePath' => dirname(__DIR__).'/web/assets'

@andris-sevcenko
Copy link
Contributor

Glad you got that sorted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants