1

I'm trying to optimise page speeds for my website. One thing I'm looking into is optimising image file sizes, but Image Transform in CraftCMS doesn't seem to work.

Before:

{% set asset = entry.providerAppBadge.one() %}
    <img src="{{ asset.getUrl()}}" alt="{{ entry.title }}" />

After:

  1. Created an 'Image transform' enter image description here

  2. Added Image transform name to the code as a string


    {% set asset = entry.providerAppBadge.one() %}
        <img src="{{ asset.getUrl('appBadge50x50')}}" alt="{{ entry.title }}" />

  1. Image does not load correctly on website. When I take a look at Google Inspect, I can see Craft CMS did load a src url (https://mywebsite.com/actions/assets/generate-transform?transformId=283), but when visiting this url directly, I get this error. enter image description here

  2. FYI, When I add width="{{ asset.getWidth('appBadge50x50') }}", it does load the 50px width correctly, so the Transform Image seems to be set up and recognised correctly.

1
  • 1
    It's not possible to tell what's going wrong from that error message alone – try enabling devMode, which should throw up a full stack trace. Alternatively, the logs in storage/logs might provide a clue. Commented Mar 6, 2022 at 20:14

1 Answer 1

1

Are you on a multi-site environment? I had a similar issue today because I did not had an absolute path set in the settings of the volume.

Make sure you have an absolute path set for the volume, e.g. /home/web123/htdocs/images. In my case, it was first set to just images and then to @webroot/images which both resulted in the error.

2
  • There goes 2 hours of my precious life… Thanks for pointing this out! Do you know why this is? I am on Craft CMS 4.3.6
    – outline4
    Commented Jan 6, 2023 at 19:07
  • I've upgraded from Craft 3 (forgot the full version) and the / was missing in the path. Didn't fix the issue but it was still missing
    – Jaytrix
    Commented Jan 30, 2023 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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