Make WordPress Core

Changeset 12039


Ignore:
Timestamp:
10/15/2009 02:27:04 PM (15 years ago)
Author:
markjaquith
Message:

Add wp-post-image CSS class to post images. see #10928

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-filters.php

    r12023 r12039  
    216216add_action('transition_post_status', '_transition_post_status', 5, 3);
    217217add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce');
     218// Post Image CSS class filtering
     219add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add' );
     220add_action( 'end_fetch_post_image_html', '_wp_post_image_class_filter_remove' );
    218221// Redirect Old Slugs
    219222add_action('template_redirect', 'wp_old_slug_redirect');
  • trunk/wp-includes/media.php

    r12035 r12039  
    557557}
    558558
     559/**
     560 * Adds a 'wp-post-image' class to post image thumbnails
     561 * Uses the begin_fetch_post_image_html and end_fetch_post_image_html action hooks to
     562 * dynamically add/remove itself so as to only filter post image thumbnails
     563 *
     564 * @author Mark Jaquith
     565 * @since 2.9.0
     566 * @param array $attr Attributes including src, class, alt, title
     567 * @return array
     568 */
     569function _wp_post_image_class_filter( $attr ) {
     570    $attr['class'] .= ' wp-post-image';
     571    return $attr;
     572}
     573
     574/**
     575 * Adds _wp_post_image_class_filter to the wp_get_attachment_image_attributes filter
     576 *
     577 * @author Mark Jaquith
     578 * @since 2.9.0
     579 */
     580function _wp_post_image_class_filter_add( $attr ) {
     581    add_filter( 'wp_get_attachment_image_attributes', '_wp_post_image_class_filter' );
     582}
     583
     584/**
     585 * Removes _wp_post_image_class_filter from the wp_get_attachment_image_attributes filter
     586 *
     587 * @author Mark Jaquith
     588 * @since 2.9.0
     589 */
     590function _wp_post_image_class_filter_remove( $attr ) {
     591    remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_image_class_filter' );
     592}
     593
    559594add_shortcode('wp_caption', 'img_caption_shortcode');
    560595add_shortcode('caption', 'img_caption_shortcode');
Note: See TracChangeset for help on using the changeset viewer.