Score:0

Media Library: How can I pre-fill the caption when an image is inserted into a text area?

in flag

If I use Media Library to insert an image into a text area, the image's caption is empty and hidden.

Instead I want the caption displayed by default, pre-filled with text in the format: [Image entity name], by [username], eg '1960s street scene, by David'

(I'm migrating a site that uses D7 + the Scald module to D9 + core Media, and I want to replicate the old site's behaviour in the new site.)

Is there any way to customise Media Library's behaviour to do this?

If there isn't, then in D7 I'd ask for a new hook that will let me change what gets written into the text area when the user inserts an image. Is that still the right approach in D9?

Score:0
in flag

I found a solution, and have written it up at: https://www.drupal.org/project/drupal/issues/3225834#comment-14341085

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.