Make WordPress Core

Ticket #19695: 19695.3.diff

File 19695.3.diff, 1.7 KB (added by ericmann, 15 years ago)

Cleaning up the code slightly to allow for situations where the function getimagesize() doesn't work (i.e. GD Image Library isn't installed with PHP).

  • wp-includes/bookmark-template.php

     
    100100
    101101                $output .= $link_before;
    102102
    103                 if ( $bookmark->link_image != null && $show_images ) {
    104                         if ( strpos($bookmark->link_image, 'http') === 0 )
    105                                 $output .= "<img src=\"$bookmark->link_image\" $alt $title />";
    106                         else // If it's a relative path
    107                                 $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
     103                if ( $bookmark->link_image != null && $show_images ) {                 
     104                        if ( strpos($bookmark->link_image, 'http') === 0 ) {
     105                                $size = @getimagesize( $bookmark->link_image );
     106                               
     107                                if( !$size )
     108                                        return new WP_Error( 'invalid_image', __('Could not read image size'), $bookmark->link_image );
     109                                       
     110                                list( $width, $height, $image_type, $size_string ) = $size;
     111                               
     112                                if ( '' != $size_string )
     113                                        $size_attrib = $size_string;
     114                               
     115                                $output .= "<img src=\"$bookmark->link_image\" $size_attrib $alt $title />";
     116                        } else { // If it's a relative path
     117                                $size = @getimagesize( get_option('siteurl') . $bookmark->link_image );
     118                               
     119                                if( !$size )
     120                                        return new WP_Error( 'invalid_image', __('Could not read image size'), get_option('siteurl') . $bookmark->link_image );
     121                                       
     122                                list( $width, $height, $image_type, $size_string ) = $size;
     123                               
     124                                if ( '' != $size_string )
     125                                        $size_attrib = $size_string;
     126                               
     127                                $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $size_attrib $alt $title />";
     128                        }
    108129
    109130                        if ( $show_name )
    110131                                $output .= " $name";