WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16795 closed enhancement (wontfix)

Add `wp-image` to images in posts

Reported by: cyberskull Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Media Keywords:
Focuses: Cc:

Description

Currently an image in in a post has the class of "image-SIZE wp-image-INT" to something like "wp-library-image image-SIZE wp-image-INT" so we can have a class for all images inserted into a post so we don't have to awkwardly code CSS for the various image-SIZEs and the wp-image-INTs.

Attachments (2)

16795.patch (789 bytes) - added by hakre 4 years ago.
Trivial to patch
wp-image.php (148 bytes) - added by hakre 4 years ago.
Plugin Variant - Works as MU-Plugin as well

Download all attachments as: .zip

Change History (7)

comment:1 @garyc404 years ago

  • Severity changed from normal to trivial

Within a theme you can use other CSS rules for that, such as '#content .post img'.

comment:2 @knutsp4 years ago

  • Cc knut@… added

I have no problem selecting all images within posts by CSS. Like this, for Twenty Ten:

.entry-content img {}

comment:3 @cyberskull4 years ago

Mainly I wanted a way to automatically style images from my wordpress media library while ignoring plug-in images in the content area.

@hakre4 years ago

Trivial to patch

@hakre4 years ago

Plugin Variant - Works as MU-Plugin as well

comment:4 @hakre4 years ago

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

Hi Cyberskull,

I can understand that you might want to have that to more easy create your theme or modify your homepage. However the feature you request is rather trivial to do, I've added a plugin that you can use (tested with PHP 5.3.5) that does the job.

Additionally there is a patch that modifies media.php with what you asked for.

If in future you have a problem with your site and you do not know how to do something, please first talk with other worpdress users, e.g. in the support forums or sites like wordpress answers. It's not that I want to prevent you from opening a ticket but it's not always clear upfront if a certain issue demands a ticket or can be solved individually with a plugin and in case there is more demand over time could become part of wordpress.

I'm sure that you would have found a solution for your problem on the bespoken sites pretty quickly.

So please do not feel offended if I close now the ticket. If you think it's really a bummer, you can consider re-opening it. But for now I would rate this as plugin-material.

Additionally: This is not a fix, but as long as CSS 3 is an option for you, you can make use of attribute susbtring selectors probably.

comment:5 @scribu4 years ago

  • Milestone Awaiting Review deleted

I agree that the filter is enough in this case.

PHP < 5.3 compatible version:

function add_wp_image_class( $class ) {
  return $class . ' wp-image';
}
add_filter('get_image_tag_class', 'add_wp_image_class');
Note: See TracTickets for help on using tickets.