WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#18497 closed enhancement (wontfix)

More flexible overriding of gallery short code default CSS

Reported by: jb510 Owned by: jb510
Milestone: Priority: normal
Severity: minor Version: 3.2.1
Component: Media Keywords: has-patch
Focuses: Cc:

Description

The default gallery CSS can be removed by filter (use_default_gallery_style), but it seems to me it'd also be nice to override the CSS conditionally on a post by post or gallery by gallery basis rather than globally and without having to write conditional statements in php to do it.

Users could then continue to use the gallery short code's automatically generated CSS, but override it selectively without needing PHP.

One option would be to pass a class into the shortcode, but I think just the ability to pass in an attribute disabling the default CSS would actually be best.

Attachments (2)

media.php.patch (691 bytes) - added by jb510 3 years ago.
media-2.php.patch (690 bytes) - added by jb510 3 years ago.

Download all attachments as: .zip

Change History (7)

jb5103 years ago

jb5103 years ago

comment:1 jb5103 years ago

  • Owner changed from Jon Brown to jb510
  • Status changed from new to assigned

comment:2 GaryJ3 years ago

A couple of pairs of parentheses can be removed from your patch, and some whitespace added, but I like this idea. Saying that though - is it likely to be a high percentage of people who want some WP default styling on some galleries, and no WP default styling on others?

Wouldn't they be better to use the filter to turn the WP default styling off completely, and then use body_class() values as selectors in their style sheet for picking which galleries have style and which don't?

.gallery {
    border: 1px solid red;
}
.postid-5 .gallery {
    border: none;
}

comment:3 azaozz3 years ago

Agree with @GaryJ. Seems we are trying to solve CSS problems or add enhancements only from PHP, resulting in needlessly complicating the code. A lot of the display options/enhancements should be handled in CSS, after all that's the proper coding language for the display :-)

This particular case can easily be solved by using more specific CSS selectors to override the defaults or even overriding the actual default selectors by including another stylesheet.

comment:4 jb5103 years ago

  • Resolution set to wontfix
  • Status changed from assigned to closed

Part of my thought behind this patch was that a lot of "average" users can add CSS to their theme but don't have the skills to add a filter in PHP further there are situations like muiltsite (where we run WordPress.com Custom CSS plugin) where users can sometimes add CSS but aren't allowed to add PHP. However I still see the utility in auto-generating the CSS such that size/columns/etc can all be accounted for dynamically.

Gary's right that I don't see a huge percentage of people needing the ability to disable the default CSS on a gallery by gallery basis and... now for the embarrassing admission... I'd forgotten the specificity needed could be added with body classes, I was thinking overriding inline css required !important.

So while I personally still think as a general rule short codes that auto-generate inline css should have an attribute to disable that CSS, I completely understand if that philosophy conflicts with the philosophy of things done in core.

TY both for looking at it.

Last edited 3 years ago by jb510 (previous) (diff)

comment:5 SergeyBiryukov3 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.