Changeset 3420609
- Timestamp:
- 12/16/2025 02:59:30 AM (4 months ago)
- Location:
- infility-global/trunk
- Files:
-
- 2 edited
-
infility_global.php (modified) (2 diffs)
-
widgets/infility-import-data/include/infility-import-site.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
infility-global/trunk/infility_global.php
r3419855 r3420609 4 4 Plugin URI: https://www.infility.cn/ 5 5 Description: Infility公共插件 6 Version: 2.14.4 16 Version: 2.14.42 7 7 Author: Infility 8 8 Author URI: https://www.infility.cn/ … … 142 142 function __construct() 143 143 { 144 define( 'INFILITY_GLOBAL_VERSION', '2.14.4 1' );144 define( 'INFILITY_GLOBAL_VERSION', '2.14.42' ); 145 145 define( 'INFILITY_GLOBAL_PATH', plugin_dir_path( __FILE__ ) ); // fullpath/wp-content/plugins/infility-global/ // 有斜杠 146 146 define( 'INFILITY_GLOBAL_URL', plugins_url( '/', __FILE__ ) ); // https://the_domain/wp-content/plugins/infility-global/ // 斜杠是自己加的 -
infility-global/trunk/widgets/infility-import-data/include/infility-import-site.php
r3397907 r3420609 793 793 } 794 794 795 public function replace_image_src($html,$site,$post_id){ 796 $dom = new \DOMDocument(); 795 public function replace_image_src($html,$site='',$post_id = 0){ 796 $dom = new \DOMDocument('1.0', 'UTF-8'); 797 797 798 // 加载HTML内容,第二个参数设置为true,以避免将HTML当作HTML实体处理 798 @$dom->loadHTML( $html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);799 @$dom->loadHTML('<?xml encoding="utf-8" ?>'.$html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); 799 800 // 移除不需要的空白节点,可选步骤,但有助于清理DOM结构 800 801 $dom->normalize(); 801 802 802 803 $imgs = $dom->getElementsByTagName('img'); 803 foreach ($imgs as $img) { 804 $src = $img->getAttribute('src'); 805 if(empty($src)){continue;} 806 $src = $this->format_link($src,$site); 807 $attach_id = $this->add_image_to_media_library($src,$post_id); 808 $image_url = wp_get_attachment_url($attach_id); 809 if(!$image_url){continue;} 810 $img->setAttribute('src', $image_url);// 修改img标签的src属性 804 if(!empty($imgs->length) && $imgs->length>0){ 805 foreach ($imgs as $img) { 806 $src = $img->getAttribute('src'); 807 if(empty($src)){continue;} 808 $src = $this->format_link($src,$site); 809 $attach_id = $this->add_image_to_media_library($src,$post_id); 810 $image_url = wp_get_attachment_url($attach_id); 811 if(!$image_url){continue;} 812 $img->setAttribute('src', $image_url);// 修改img标签的src属性 813 } 811 814 } 812 815 … … 815 818 } 816 819 817 public function format_link($link,$site ){820 public function format_link($link,$site=''){ 818 821 $parsed_url = parse_url($link); 819 822 if(!isset($parsed_url['host'])){ … … 1275 1278 $attach_id = $this->add_image_to_media_library($data); 1276 1279 $format_value = $attach_id; 1280 }else if($type=='wysiwyg'){ 1281 if(is_array($data)){ 1282 $format_value = ''; 1283 foreach($data as $k=>$v){ 1284 $format_value .= $this->replace_image_src($v,'').PHP_EOL; 1285 } 1286 }else{ 1287 $format_value = $this->replace_image_src($data,''); 1288 } 1277 1289 }else{ 1278 1290 if(is_array($data)){
Note: See TracChangeset
for help on using the changeset viewer.