Closed anita-chouhan closed 1 month ago
I'm not able to reproduce that.
Where does the html
variable come from and what does it contain? If you do a {{ dump(html) }}
in your template, what does the output look like (a screen dump is fine, if you can share)?
The variable contains the rich text content from CKEditor. Here is the output of {{ dump(html) }}
and {{ dump(html|retconAutoAlt) }}
.
The asset title is Colorful bird and file name is bird-thumbnail.jpeg. I was expecting the alt to show Colorful bird and not bird-thumbnail.
Thanks for the extra info!
The reason why retconAutoAlt
isn’t able to output the asset’s title is because your CKEditor field’s output has already been rendered to a string (or rather, a Twig\Markup
object) - hence the reference tags found in raw CKEditor output have been lost. For the autoAlt feature, Retcon relies on those tags for querying for the original asset, falling back to using the file name if it can’t be found.
Most likely, this occurs because the CKEditor output has been passed through another Twig filter (or some other operation that renders its raw content down to a Twig markup object), before the retconAutoAlt
operation.
To ensure that the retconAutoAlt
filter works as intended, make sure that this filter is the first operation on the CKEditor output.
Okay, thank you for looking into it. I'll check for the other filters.
I can recreate this same behavior. I've ensured that the very first filter applied is retconAutoAlt
, and even tested turning Purify HTML
off for the filter, and still no matter how I set the three options, or if I just leave them as default, I'm getting the filename output as the alt text value. I'm on Craft 5.4.7.1 and Retcon 3.2.0. I also had some other Retcon filters I was applying and I tested removing all of them and still got the same result.
@itsmattsoria Can you share the relevant Twig code where this is occurring? Are you using CKEditor or Redactor?
@mmikkel I'm sorry, I'm using CKEditor 4.2.0. Here's my twig code:
{{ entry.longFormContent|retconAutoAlt(null, false, false) }}
Where longFormContent
is a CKEditor field.
Thanks @itsmattsoria, I'm able to reproduce. Seems like it's isolated to Craft 5/Retcon 3.x. I'll get a fix out ASAP.
@mmikkel Amazing—thank you!
This turned out to be a regression introduced in https://github.com/mmikkel/Retcon-Craft/commit/17a58efd73c248e9b7304771c7a9b95d339466ee (only affects the Craft 5 version of Retcon). I'll get a release out w/ the fix as soon as possible, but there are a couple of other things I'm hoping to get to. If you need it straight it away, change your Composer dependency for Retcon in composer.json
to
"mmikkel/retcon": "dev-master#dcd459ac22f9fa54b9b149e9057d4ec83c98c6c0 as 3.2.0"
...then run composer update
.
@mmikkel awesome, thanks!
@itsmattsoria Retcon v. 3.2.1 is out now with that fix for Craft 5.
@mmikkel amazing, thank you!
The
retconAutoAlt
renders the asset's filename in place of the title (as mentioned in the doc).Expected
{{ html |retconAutoAlt }}
Asset title asalt
tag value if no alt value is supplied by the author for the rich content field image.Outcome
{{ html |retconAutoAlt }}
Asset filename asalt
tag value if no alt value is supplied.Plugin version 2.8.0
Craft CMS version 4.9.7