Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#34396 new enhancement

Gallery shortcode : make image captions relative to the current gallery

Reported by: fab1en's profile Fab1en Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Gallery Keywords:
Focuses: administration Cc:


In the media frame, the "Caption" field is used to set a caption for images. But this field has several other effects that are not always intended by the website author.

  • Changes to this field are saved on the database (in the excerpt field of the attachment post) as soon as the field is unfocused : no preview is possible, changes are put online directly. Changes are still applied even if "Update" button is not clicked.
  • For single image insertion, caption is saved in the post content, inside the [caption] shortcode. But for multiple images, caption is saved globally, not inside the [gallery] shortcode.
  • When modifying a gallery, changing the caption field right under the image also updates the caption field on the right panel, and saves it globally when the focus is moved. So even when the "Update gallery" button is not clicked, the changes are still saved in the database, but they are not reflected in the editor until the page is reloaded.
  • When an image is use in several galleries, updating the caption associated with this image in one gallery also updates the caption on the other gallery. This is very different from the behavior of other fields displayed on the right panel (columns, link to, size) that change only the current gallery.
  • Modifying the caption field is the attachment details edition view or in the media library grid view will change the caption used for this image in a gallery.

Change History (1)

#1 @Fab1en
9 years ago

I see two directions to make this happen :

  1. Store the caption of images is the gallery directly in the gallery shortcode. That is not possible today (because HTML is not allowed in shortcode attributes) but it could be possible with the future shortcode format that will allow to split shortcode content into several parts, each part being an image caption.
  2. Store the caption in a postmeta field, linking it to the gallery id. This is easier to achieve but will not solve the previewing issue.
Note: See TracTickets for help on using tickets.