Changeset 2383 for trunk/bp-activity.php
- Timestamp:
- 01/20/2010 05:43:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2382 r2383 487 487 $content = bp_activity_add_timesince_placeholder( $content ); 488 488 489 /* Remove any images and replace the first image with a thumbnail */490 //$content = bp_activity_thumbnail_images( $content );491 492 489 $activity = new BP_Activity_Activity( $id ); 493 490 … … 710 707 } 711 708 712 function bp_activity_thum bnail_images( $content ) {709 function bp_activity_thumnail_content_images( $content ) { 713 710 preg_match_all( '/<img[^>]*>/Ui', $content, $matches ); 714 711 $content = preg_replace('/<img[^>]*>/Ui', '', $content ); … … 718 715 preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src ); 719 716 717 /* Get the width and height */ 718 preg_match( '/<img.*?(height\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $height ); 719 preg_match( '/<img.*?(width\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $width ); 720 720 721 if ( !empty( $src ) ) { 721 722 $src = substr( substr( str_replace( 'src=', '', $src[1] ), 0, -1 ), 1 ); 722 $pos = strpos( $content, '<blockquote>' ); 723 $before = substr( $content, 0, (int) $pos ); 724 $after = substr( $content, (int) $pos, strlen( $content ) ); 725 726 $content = $before . '<img src="' . esc_attr( $src) . '" width="100" height="100" alt="thumb" class="align-left thumbnail" />' . $after; 723 $height = substr( substr( str_replace( 'height=', '', $height[1] ), 0, -1 ), 1 ); 724 $width = substr( substr( str_replace( 'width=', '', $width[1] ), 0, -1 ), 1 ); 725 726 if ( empty( $width ) || empty( $height ) ) { 727 $width = 100; 728 $height = 100; 729 } 730 731 $ratio = (int)$width / (int)$height; 732 $new_height = 100; 733 $new_width = $new_height * $ratio; 734 735 $content = '<img src="' . esc_attr( $src) . '" width="' . $new_width . '" height="' . $new_height . '" alt="' . __( 'Thumbnail', 'buddypress' ) . '" class="align-left thumbnail" />' . $content; 727 736 } 728 737 }
Note: See TracChangeset
for help on using the changeset viewer.