Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What is the best way to allow a longer caption when embedding? Would it make sense to change the caption element type to textarea? Or have a setting for the length of the textfield?
I struggled for a while to alter the form element with hook_form_alter but did not succeed.
Comment | File | Size | Author |
---|---|---|---|
#18 | entity_embed-allow-longer-captions-2833233-18.patch | 686 bytes | Daniel Korte |
| |||
#2 | entity_embed-allow-longer-captions-2833233-2.patch | 673 bytes | Daniel Korte |
Comments
Comment #2
Daniel KorteI needed this too. Patch attached.
Comment #3
Daniel KorteComment #5
marcoscanoTriggering test bot again
Comment #6
AnybodyThis makes a lot of sense. We'll test this manually in addition. Thank you.
Comment #7
AnybodyThe patch works perfectly. The 8.5 test fails are unrelated to this patch. Setting this RTBC and would love to see this in the next release.
Comment #8
thomas.frobieterI agree.
Should we allow HTML in this field?
Or simply add |nl2br in the template file (filter-caption.html.twig)?
Comment #9
skyriter CreditAttribution: skyriter at Creighton University commentedI just noticed this issue. Is there a timeline for when this patch will be added to the module?
Please forgive my naïveté if the answer is somewhere else or patently obvious even to the most casual observer.
Comment #10
AnybodyConfirming patch still applies and should be part of the next release. Is there a release planned by the maintainer?
Comment #11
DakwamineStill applies on 1.0.0-beta2.
+1 for having it going official.
Comment #12
Daniel Korte@thomas.frobieter I prefer HTML allowed here since it is the WYSIWYG filters’ job to remove anything that isn’t allowed. I don’t think filter-caption.html.twig should be changed because of this issue.
@Anybody Three years running: #2577891: Entity Embed 8.x-1.0.0-rc1 release
Comment #13
DakwamineI agree with Daniel Korte.
In fact, this is an Entity Embed issue which escapes the input instead of letting the caption filter handle it. I have created an issue a few minutes ago about this: #2990624: Cannot insert valid HTML tags in captions + test coverage for interaction with core's FilterCaption.
I have provided an update to an old unmerged patch on core to make this caption filter configurable: #2508421: FilterCaption hard-codes allowed tags.
Comment #14
AnybodyI also agree with #12 and #13 for maximum flexibility.
Comment #15
ChrisSnyder+1 for having it going official.
Comment #16
Wim LeersCorrect, it's
\Drupal\filter\Plugin\Filter\FilterCaption
that handles this, and that determines restrictions. Just like #13 says. I left a comment at #2990624: Cannot insert valid HTML tags in captions + test coverage for interaction with core's FilterCaption to help get that fixed forever :)This issue is then solely about changing the UI to allow more text to be entered as the caption. I don't see a reason to oppose this. Ideally though, this captioning stuff would NOT live in the Entity Embed module, it'd just use the existing CKEditor Widget to edit captions in-place. But that's out-of-scope for this issue.
So I think this is a zero-risk, nice improvement that benefits most sites, since likely quite a few captions are longer than a single line.
Comment #17
phenaproxima+1 for this change, but I think that we should set the number of rows of the textarea to 2 or 3, so that this doesn't look like a gaping huge textarea where people can enter a paragraph's worth of caption.
Comment #18
Daniel KorteI used three rows since that is used in core six times and two rows does not appear to be used.
Comment #19
Chris Matthews CreditAttribution: Chris Matthews commentedThe patch to EntityEmbedDialog.php in #18 applied cleanly and works perfectly for me, but another review before RTBC wouldn't hurt.
Comment #20
AnybodyI agree and RTBC.
Comment #21
Wim LeersLGTM!
Comment #22
oknateRTBC by me as well.
Comment #24
phenaproximaCommitted and pushed to 8.x-1.x. Thanks!