WordPress.org

Plugin Directory

Changeset 627272


Ignore:
Timestamp:
11/19/12 20:27:21 (17 months ago)
Author:
mdawaffe
Message:

Post Images: Fix regex for matching images in HTML so that it doesn't require self-closed tags (<img />), which meant that it was missing images in a lot of hand-coded posts.

Props @beau

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/class.jetpack-post-images.php

    r622440 r627272  
    180180            ); 
    181181        } 
    182          
     182 
    183183        /* 
    184184        * We only want to pass back attached images that were actually inserted. 
     
    188188        $html_images = array(); 
    189189        $html_images = self::from_html( get_post( $post_id ) ); 
    190  
    191190        $inserted_images = array(); 
    192          
     191 
    193192        foreach( $html_images as $html_image ) { 
    194193            $src = parse_url( $html_image['src'] ); 
    195             $inserted_images[] = $src['scheme'] . '://' . $src['host'] . $src['path']; // strip off any query strings  
     194            $inserted_images[] = $src['scheme'] . '://' . $src['host'] . $src['path']; // strip off any query strings 
    196195        } 
    197196        foreach( $images as $i => $image ) { 
     
    258257        } 
    259258 
    260         preg_match_all( '!<img.*src="([^"]+)".*/>!iUs', $html, $matches ); 
     259        preg_match_all( '!<img.*src="([^"]+)".*/?>!iUs', $html, $matches ); 
    261260        if ( !empty( $matches[1] ) ) { 
    262261            foreach ( $matches[1] as $match ) { 
     
    387386        $media = apply_filters( 'jetpack_images_pre_get_images', $media, $post_id, $args ); 
    388387        if ( $media ) 
    389             return $media;  
     388            return $media; 
    390389 
    391390        $defaults = array( 
    392             'width' => 200,  // Required minimum width (if possible to determine) 
    393             'height' => 200, // Required minimum height (if possible to determine) 
    394             'avatar_size' => 96, 
     391            'width'               => 200,  // Required minimum width (if possible to determine) 
     392            'height'              => 200, // Required minimum height (if possible to determine) 
     393            'avatar_size'         => 96, 
    395394            'fallback_to_avatars' => false, 
    396             'gravatar_default' => false, 
     395            'gravatar_default'    => false, 
    397396        ); 
    398397        $args = wp_parse_args( $args, $defaults ); 
Note: See TracChangeset for help on using the changeset viewer.