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

[4.x]: asset.getImg() for image with only a transform url returns null #11614

Closed
codebarista opened this issue Jul 16, 2022 · 2 comments
Closed

Comments

@codebarista
Copy link

What happened?

Description

I store images without URL in storage and only define a URL for the transforms. In Twig when I call the function asset.getImg('existing_transform') it returns NULL.

Steps to reproduce

  1. Create filesytem "Images" w/o public URL and Base Path @storage/assets/images
  2. Create filesytem "Transforms" with public URL and Base Path @webroot/assets/images
  3. Create Assets Volume "Images" with Asset Filesystem "Images" and Transform Filesystem "Transforms"
  4. Create Image Transforms, e.g. "large"
  5. Add an image to an entry
  6. Call asset.getImg('large') in a Twig template

Expected behavior

Return the image tag with image transformation.

Actual behavior

Returns null

Dirty Quick Fix

In elements/Asset.php line 1195 add the following:

if (!$volume->getFs()->hasUrls && !$transform) {
    return null;
}

Craft CMS version

Craft Pro 4.1.4.1

PHP version

8.1.7

Operating system and version

Linux 5.10.104-linuxkit

Database type and version

MySQL 8.0.29

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-35)

Installed plugins and versions

  • Redactor 3.0.2
@brandonkelly
Copy link
Member

Thanks for reporting that! Fixed now for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to "dev-develop as 4.1.4.1" and run composer update.

@brandonkelly
Copy link
Member

Craft 4.2.0 is out now with that fix.

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

No branches or pull requests

2 participants