Changeset 2972681
- Timestamp:
- 09/28/2023 02:16:18 PM (2 years ago)
- Location:
- wp-smartcrop
- Files:
-
- 4 edited
- 1 copied
-
tags/2.0.7 (copied) (copied from wp-smartcrop/trunk)
-
tags/2.0.7/readme.txt (modified) (1 diff)
-
tags/2.0.7/wp-smartcrop.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-smartcrop.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-smartcrop/tags/2.0.7/readme.txt
r2744222 r2972681 111 111 == Changelog == 112 112 113 = 2.0.7 = 114 * Add support for figure markup 115 113 116 = 2.0.6 = 114 117 * Test against WordPress 5.6.0 -
wp-smartcrop/tags/2.0.7/wp-smartcrop.php
r2744222 r2972681 4 4 * Plugin URI: https://www.wpsmartcrop.com/ 5 5 * Description: Style your images exactly how you want them to appear, for any screen size, and never get a cut-off face. 6 * Version: 2.0. 66 * Version: 2.0.7 7 7 * Author: Bytes.co 8 8 * Author URI: https://bytes.co … … 13 13 if( !class_exists('WP_Smart_Crop') ) { 14 14 class WP_Smart_Crop { 15 public $version = '2.0. 6';15 public $version = '2.0.7'; 16 16 private $plugin_dir_path; 17 17 private $plugin_dir_url; … … 432 432 function the_content( $content ) { 433 433 $tags = $this->extract_tags( $content, 'img', true, true ); 434 $figure_tags = $this->extract_tags( $content, 'figure', false, true ); // wordpress can attach size details to a figure wrapper now 435 $tags = array_merge( $tags, $figure_tags ); 436 434 437 $unique_tags = array(); 435 438 $ids = array(); 436 439 foreach( $tags as $tag ) { 437 list( $id, $size ) = $this->get_id_and_size_from_tag( $tag ); 440 $id = null; 441 $size = null; 442 if ( $tag['tag_name'] == 'img' ) { 443 list( $id, $size ) = $this->get_id_and_size_from_tag( $tag ); 444 } elseif ( $tag['tag_name'] == 'figure' ) { // specially process our figure tags to get size data 445 $img_tag = $this->extract_tags( $tag['full_tag'] ?? '', 'img', true, true ); 446 // we're processing only the first img 447 if ( $img_tag && count($img_tag) ) { 448 $img_tag = $img_tag[0]; 449 $tag['img_tag'] = $img_tag; 450 } else { 451 continue; 452 } 453 $img_tag['attributes']['class'] .= $tag['attributes']['class']; 454 list( $id, $size ) = $this->get_id_and_size_from_tag( $img_tag ); 455 } 456 //var_dump( $size ); 438 457 if( $id && $size ) { 439 458 $ids[] = $id; … … 725 744 $id = $tag['id']; 726 745 $size = $tag['size']; 727 $atts = $tag[' attributes'];746 $atts = $tag['img_tag']['attributes'] ?: $tag['attributes']; 728 747 $focus_attr = $this->get_smartcrop_focus_attr( $id, $size ); 729 748 if( $focus_attr ) { … … 736 755 $atts['data-smartcrop-focus'] = $focus_attr; 737 756 } 738 $new_tag = '<img'; 757 $value = ''; 758 $old_img_tag = $tag['full_tag']; 759 // special processing for figure tags 760 if ( $tag['tag_name'] == 'figure' ) { 761 $old_img_tag = $tag['img_tag']['full_tag'] ?? null; 762 } 763 $new_img_tag = '<img'; 739 764 foreach( $atts as $name => $val ) { 740 $new_tag .= ' ' . $name . '="' . $val . '"'; 741 } 742 $new_tag .= ' />'; 765 $new_img_tag .= ' ' . $name . '="' . $val . '"'; 766 } 767 $new_img_tag .= ' />'; 768 $new_tag = str_replace( $old_img_tag, $new_img_tag, $tag['full_tag'] ); 743 769 return $new_tag; 744 770 } -
wp-smartcrop/trunk/readme.txt
r2744222 r2972681 111 111 == Changelog == 112 112 113 = 2.0.7 = 114 * Add support for figure markup 115 113 116 = 2.0.6 = 114 117 * Test against WordPress 5.6.0 -
wp-smartcrop/trunk/wp-smartcrop.php
r2744222 r2972681 4 4 * Plugin URI: https://www.wpsmartcrop.com/ 5 5 * Description: Style your images exactly how you want them to appear, for any screen size, and never get a cut-off face. 6 * Version: 2.0. 66 * Version: 2.0.7 7 7 * Author: Bytes.co 8 8 * Author URI: https://bytes.co … … 13 13 if( !class_exists('WP_Smart_Crop') ) { 14 14 class WP_Smart_Crop { 15 public $version = '2.0. 6';15 public $version = '2.0.7'; 16 16 private $plugin_dir_path; 17 17 private $plugin_dir_url; … … 432 432 function the_content( $content ) { 433 433 $tags = $this->extract_tags( $content, 'img', true, true ); 434 $figure_tags = $this->extract_tags( $content, 'figure', false, true ); // wordpress can attach size details to a figure wrapper now 435 $tags = array_merge( $tags, $figure_tags ); 436 434 437 $unique_tags = array(); 435 438 $ids = array(); 436 439 foreach( $tags as $tag ) { 437 list( $id, $size ) = $this->get_id_and_size_from_tag( $tag ); 440 $id = null; 441 $size = null; 442 if ( $tag['tag_name'] == 'img' ) { 443 list( $id, $size ) = $this->get_id_and_size_from_tag( $tag ); 444 } elseif ( $tag['tag_name'] == 'figure' ) { // specially process our figure tags to get size data 445 $img_tag = $this->extract_tags( $tag['full_tag'] ?? '', 'img', true, true ); 446 // we're processing only the first img 447 if ( $img_tag && count($img_tag) ) { 448 $img_tag = $img_tag[0]; 449 $tag['img_tag'] = $img_tag; 450 } else { 451 continue; 452 } 453 $img_tag['attributes']['class'] .= $tag['attributes']['class']; 454 list( $id, $size ) = $this->get_id_and_size_from_tag( $img_tag ); 455 } 456 //var_dump( $size ); 438 457 if( $id && $size ) { 439 458 $ids[] = $id; … … 725 744 $id = $tag['id']; 726 745 $size = $tag['size']; 727 $atts = $tag[' attributes'];746 $atts = $tag['img_tag']['attributes'] ?: $tag['attributes']; 728 747 $focus_attr = $this->get_smartcrop_focus_attr( $id, $size ); 729 748 if( $focus_attr ) { … … 736 755 $atts['data-smartcrop-focus'] = $focus_attr; 737 756 } 738 $new_tag = '<img'; 757 $value = ''; 758 $old_img_tag = $tag['full_tag']; 759 // special processing for figure tags 760 if ( $tag['tag_name'] == 'figure' ) { 761 $old_img_tag = $tag['img_tag']['full_tag'] ?? null; 762 } 763 $new_img_tag = '<img'; 739 764 foreach( $atts as $name => $val ) { 740 $new_tag .= ' ' . $name . '="' . $val . '"'; 741 } 742 $new_tag .= ' />'; 765 $new_img_tag .= ' ' . $name . '="' . $val . '"'; 766 } 767 $new_img_tag .= ' />'; 768 $new_tag = str_replace( $old_img_tag, $new_img_tag, $tag['full_tag'] ); 743 769 return $new_tag; 744 770 }
Note: See TracChangeset
for help on using the changeset viewer.