Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.