spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
104 stars 29 forks source link

Additional image fields not passed #165

Closed codedge closed 2 years ago

codedge commented 2 years ago

In my containers blueprint for images I defined an additional field called label.

2022-08-29 at 09 11 36@2x

When I want to use this new label filed in the template I cannot access it. I try it like this:

{{ responsive:header_image ratio="21/9" quality:webp="80" glide:width="3200" title="{label}" }}

The generated html contains the alt attribute, but not the label.

2022-08-29 at 09 15 19@2x

Anything I am doing wrong or is this a bug?

Lates version Statamic and latest version 2.13.1 of this extension here.

ncla commented 2 years ago

Where exactly is {label} coming from in your Antlers front-end template though? This addon does not augment the custom asset blueprint values in a fancy way or make them available. You would have to do something like this yourself to make label available to responsive tag (not tested, just theoretically something like this should work):

{{ asset url="/header_image.png" }}
  {{ responsive:header_image ratio="21/9" quality:webp="80" glide:width="3200" title="{label}" }}
{{ /asset }}

Alternatively you could try publishing the blade.php templates into your project and update responsiveImage.blade.php and add title="{{ $asset['label'] }}" attribute to img. Again I have not tested it, just writing in theory.