Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/09/2015 09:35:35 AM (7 years ago)
Author:
djpaul
Message:

Activity: update bp_activity_thumbnail_content_images to check that height/width attributes exist on <img> tags before trying to reference them.

Prevents PHP Notices in edge cases involving developers putting custom content through this function.

Fixes #6159

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r9384 r9456  
    26192619        preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i',  $matches[0][0], $width  );
    26202620
    2621         if ( !empty( $src ) ) {
    2622             $src    = substr( substr( str_replace( 'src=',    '', $src[1]    ), 0, -1 ), 1 );
    2623             $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
    2624             $width  = substr( substr( str_replace( 'width=',  '', $width[1]  ), 0, -1 ), 1 );
     2621        if ( ! empty( $src ) ) {
     2622            $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 );
     2623
     2624            if ( isset( $width[1] ) ) {
     2625                $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 );
     2626            }
     2627
     2628            if ( isset( $height[1] ) ) {
     2629                $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 );
     2630            }
    26252631
    26262632            if ( empty( $width ) || empty( $height ) ) {
Note: See TracChangeset for help on using the changeset viewer.