Skip to content

How to get file path to transformed image? #11408

Answered by brandonkelly
wsydney76 asked this question in Ideas
Discussion options

You must be logged in to vote

We should make this easier down the road for sure. For now, you can expose getTransformSubpath() as a public method by providing your own ImageTransformer class that extends craft\imagetransforms\ImageTransformer, like so:

namespace my\namespace;

use craft\elements\Asset;
use craft\imagetransforms\ImageTransformer;
use craft\models\ImageTransformIndex;

class MyImageTransformer extends ImageTransformer
{
    public function getTransformSubpath(Asset $asset, ImageTransformIndex $transformIndex): string
    {
        return parent::getTransformSubpath($asset, $transformIndex);
    }
}

Then you can have Craft use your own ImageTransformer class instead of carft\imagetransforms\ImageTransformer

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wsydney76
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants