Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#28997 new enhancement

Adding additional classes to image captions via UI

Reported by: jpswade's profile jpswade Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: 2nd-opinion
Focuses: Cc:


This is a follow-up to #25295.

In the "Advanced Settings" of an image, you can already set the classes of the image and the link, but not the caption.

Although you can now add a class to the caption manually under the "code" tab, there is no UI in the "Image Details/Advanced Options" of the image that actually allow you to add the class as you would expect.

The reason why I've escalated this to a feature request, rather than an arbitrary hack or plugin is this; for the end user, if you can add classes to the image and the link, you'd expect to be able to add classes for the caption, since this is a "caption" shortcode we're talking about here.

Although issue #25295 does now permit classes in the shortcode, it does not add a user interface.

Change History (5)

#1 follow-up: @jpswade
10 years ago

  • Type changed from feature request to defect (bug)

For clarification, as of 3.9 it's now called "ADVANCED OPTIONS" not "Advanced Settings".

As you can see there is an option to add an "Image CSS Class" and a "Link CSS Class", but not one for a "Caption CSS Class".

Changed to a bug as now that the [caption] shortcode accepts a class it is a missing feature.

#2 in reply to: ↑ 1 ; follow-ups: @joemcgill
9 years ago

  • Keywords 2nd-opinion added

Replying to jpswade:

At the risk of sounding redundant to the comments on #25295, the result you're looking for can be accomplished by adding a class to the image and using a CSS adjacent selector in your stylesheet to style captions based on the image class. So, for example, if you were to add a .red-caption class to the image, you could style the caption like this:

.red-text + .wp-caption-text { color: red; }

As many have suggested on the other ticket, I'm not sure it's worth adding extra UI for this particular case.

#3 @iseulde
9 years ago

  • Type changed from defect (bug) to enhancement
  • Version 3.9.1 deleted

#4 in reply to: ↑ 2 @jpswade
8 years ago


For developers, sure, CSS adjacent selectors are fine.

However, the end user, if they can add classes to the image and the link, then would expect to be able to add classes for the caption.

Issue #25295 adds the ability to pass a class to the shortcode, the problem we're trying to solve here is passing the class from the UI.

#5 in reply to: ↑ 2 @asterbird
8 years ago

CSS adjacent selectors apply to elements after the selected element. The figure element is before the img element, which makes renders CSS adjacent selectors irrelevant. See this topic about CSS's inability to directly select previous siblings:

I too would like to see this bug fixed. I have several use cases and run into the issue of a lack of adequate classes on the Figure element for just about every website I build.

Note: See TracTickets for help on using tickets.