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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xenophyle created an issue. See original summary.

Daniel Korte’s picture

Daniel Korte’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: entity_embed-allow-longer-captions-2833233-2.patch, failed testing.

marcoscano’s picture

Title: Longer captions » Use textarea to allow longer captions
Category: Support request » Feature request
Status: Needs work » Needs review
Issue tags: +D8Media

Triggering test bot again

Anybody’s picture

This makes a lot of sense. We'll test this manually in addition. Thank you.

Anybody’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

thomas.frobieter’s picture

I agree.

Should we allow HTML in this field?

Or simply add |nl2br in the template file (filter-caption.html.twig)?

<figcaption>
     {{ caption|nl2br }}
</figcaption>
skyriter’s picture

I 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.

Anybody’s picture

Confirming patch still applies and should be part of the next release. Is there a release planned by the maintainer?

Dakwamine’s picture

Still applies on 1.0.0-beta2.

+1 for having it going official.

Daniel Korte’s picture

@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

Dakwamine’s picture

I 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.

Anybody’s picture

I also agree with #12 and #13 for maximum flexibility.

ChrisSnyder’s picture

+1 for having it going official.

Wim Leers’s picture

Title: Use textarea to allow longer captions » Use textarea instead of textfield in EntityEmbedDialog, to allow longer captions
Priority: Normal » Minor
Issue tags: +Media Initiative

I prefer HTML allowed here since it is the WYSIWYG filters’ job to remove anything that isn’t allowed.

Correct, 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.

phenaproxima’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -D8Media

+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.

Daniel Korte’s picture

Status: Needs work » Needs review
FileSize
686 bytes

I used three rows since that is used in core six times and two rows does not appear to be used.

Chris Matthews’s picture

The patch to EntityEmbedDialog.php in #18 applied cleanly and works perfectly for me, but another review before RTBC wouldn't hurt.

Anybody’s picture

Status: Needs review » Reviewed & tested by the community

I agree and RTBC.

Wim Leers’s picture

LGTM!

oknate’s picture

RTBC by me as well.

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.