liip / LiipImagineBundle

Symfony Bundle to assist in image manipulation using the imagine library
http://liip.ch
MIT License
1.66k stars 378 forks source link

getBrowserPath returns cached URL for type that was not requested #1526

Open wouterSkepp opened 1 year ago

wouterSkepp commented 1 year ago

The CacheManager::getBrowserPath returns a path or url for a previously cached asset. However, the parameter for the URL generator is not within scope of the caching mechanism, possibly returning unexpected results.

Preconditions

LiipImagineBundle 2.x

Steps to reproduce

Create a template that exposes an asset through multiple variations of the UrlGeneratorInterface types (e.g. absolute url, absolute path)

<img src="{{ 'cats.jpg'|imagine_filter('my_thumb', {}, null, constant('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_URL')) }}" alt="Absolute"/>
<img src="{{ 'cats.jpg'|imagine_filter('my_thumb', {}, null, constant('Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface::ABSOLUTE_PATH')) }}" alt="Path"/>

Expected result

I expect the template to render as follows:

<img src="http://example.com/media/cache/my_thumb/cats.jpg" alt="Absolute"/>
<img src="/media/cache/my_thumb/cats.jpg" alt="Path"/>

Actual result

<img src="http://example.com/media/cache/my_thumb/cats.jpg" alt="Absolute"/>
<img src="http://example.com/media/cache/my_thumb/cats.jpg" alt="Path"/>

This is happening because CacheManager::getBrowserPath returns ResolverInterface::resolve(), which does not have the referenceType as a parameter.

ytilotti commented 8 months ago

Same issue here. Real problem to addPart on email