使WordPress成为核心

变更集57267


忽略:
时间戳:
2024年10月1日下午09:57:50(5个月(之前)
作者:
乔多尔森
消息:

媒体:修复多字节exif描述元数据的处理。

如果需要多字节字符,exif标准希望使用UserComment字段代替ImageDescription。WordPress媒体只映射了ImageDescription字段,没有正确处理带有多字节字符的描述。

修复元数据保存,以便更好地处理元数据中具有多字节字符的媒体,并更新单元测试。

Props fotodrachen、antpb、joedolson、mikinc860、azaozz、nicolefurlan。
修复#58082.

位置:
大旅行箱
文件夹:
2已编辑

图例:

未修改
补充
远离的
  • trunk/src/wp-admin/includes/image.php

    56743兰特 57267兰特  
    864864        }
    865865
     866$exif_description=“”;
     867$exif_usercomment=“”;
    866868if(!空($exif['ImageDescription'])){
     869$exif_description=修剪($exif['ImageDescription']);
     870        }
     871
     872if(!空($exif['COMPUTED']['UserComment'])){
     873$exif_usercomment=trim($exif['COMPUTED']['usercomment']);
     874        }
     875
     876if($exif_description){
    867877mbstring_binary_safe_encoding();
    868 $description_length=字符串($exif[“图像描述”]);
     878$description_length=字符串($exif_说明);
    869879重置删除编码();
    870 
    871880if(空($meta['title'])&&$description_length<80){
    872881//假设标题存储在ImageDescription中。
    873 $meta['title']=修剪($exif['ImageDescription']);
    874             }
    875 
    876 if(空($meta['caption'])&&!空($exif['COMPUTED']['UserComment']){
    877 $meta['caption']=修剪($exif['COMPUTED']['UserComment']);
     882$meta['title']=$exif_description;
     883}
     884
     885//如果同时存在用户注释和描述。
     886if(空($meta['caption'])&&$exif_description&&$exif_usercomment){
     887if(!空($meta['title'])&&$exif_description===$meta['title']){
     888$caption=$exif_usercomment;
     889}其他{
     890if($exif_description===$exif_usercomment){
     891$caption=$exif_description;
     892}其他{
     893$caption=修剪($exif_description.''.$exif_usercomment);
     894                    }
     895                }
     896$meta['caption']=$caption;
     897            }
     898
     899if(空($meta['caption'])&&$exif_usercomment){
     900$meta['caption']=$exif_usercomment;
    878901            }
    879902
    880903if(空($meta['caption']){
    881 $meta['caption']=修剪($exif['ImageDescription']);
     904$meta['caption']=$exif_description;
     905            }
     906}elseif(空($meta['caption'])&&$exif_usercomment){
     907$meta['caption']=$exif_usercomment;
     908$description_length=字符串($exif_usercomment);
     909if(空($meta['title'])&&$description_length<80){
     910$meta['title']=修剪($exif_usercomment);
    882911            }
    883912}elseif(空($meta['caption'])&&!空($exif[注释]){
  • trunk/tests/phpunit/tests/image/meta.php

    52269兰特 57267兰特  
    5252$this->assertSame('',$out['credit'],'credit value not the same’);
    5353$this->assertSame('NIKON D70',$out['camera'],'camera value not same');
    54 $this->资产相同('',$out['caption'],'字幕值不一样');
     54$this->assertSame('Alex Shiels版权所有',$out['caption'],'字幕值不一样');
    5555$this->assertEquals(strtotime('2007-06-17 21:18:00'),$out['created_timestamp'],'timestamp value not equivalent');
    5656$this->assertSame(“”,$out['copyright'],'版权价值不同');
     
    5858$this->assertEquals(0,$out['iso'],'iso值不等价');//有趣-尼康迷?
    5959$this->assertEquals(1/500,$out['shutter_speed'],'快门速度值不相等');
    60 $this->资产相同('',$out['title'],'标题值不同');
     60$this->资产相同('Alex Shiels版权所有',$out['title'],'标题值不同');
    6161//$this->assertSame(数组('Flowers'),$out['keywords']);
    6262    }
注:请参见TracChangeset(跟踪变更集)获取有关使用变更集查看器的帮助。