本文整理汇总了PHP中wp_exif_frac2dec函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_exif_frac2dec函数的具体用法?PHP wp_exif_frac2dec怎么用?PHP wp_exif_frac2dec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_exif_frac2dec函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: bwg_wp_read_image_metadata
private function bwg_wp_read_image_metadata($file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '', 'orientation' => 0);
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (!empty($iptc['2#105'][0])) {
$meta['title'] = trim($iptc['2#105'][0]);
} elseif (!empty($iptc['2#005'][0])) {
$meta['title'] = trim($iptc['2#005'][0]);
}
if (!empty($iptc['2#120'][0])) {
$caption = trim($iptc['2#120'][0]);
if (empty($meta['title'])) {
mbstring_binary_safe_encoding();
$caption_length = strlen($caption);
reset_mbstring_encoding();
if ($caption_length < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
if (!empty($iptc['2#110'][0])) {
$meta['credit'] = trim($iptc['2#110'][0]);
} elseif (!empty($iptc['2#080'][0])) {
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
$meta['copyright'] = trim($iptc['2#116'][0]);
}
}
}
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (empty($meta['title']) && !empty($exif['Title'])) {
$meta['title'] = trim($exif['Title']);
}
if (!empty($exif['ImageDescription'])) {
mbstring_binary_safe_encoding();
$description_length = strlen($exif['ImageDescription']);
reset_mbstring_encoding();
if (empty($meta['title']) && $description_length < 80) {
$meta['title'] = trim($exif['ImageDescription']);
if (empty($meta['caption']) && !empty($exif['COMPUTED']['UserComment']) && trim($exif['COMPUTED']['UserComment']) != $meta['title']) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
} elseif (empty($meta['caption']) && trim($exif['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (empty($meta['caption']) && !empty($exif['Comments']) && trim($exif['Comments']) != $meta['title']) {
$meta['caption'] = trim($exif['Comments']);
}
if (empty($meta['credit'])) {
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
}
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']);
}
if (!empty($exif['Orientation'])) {
$meta['orientation'] = $exif['Orientation'];
}
}
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
//.........这里部分代码省略.........
开发者ID:jun200,项目名称:wordpress,代码行数:101,代码来源:model.php
示例2: wp_read_image_metadata
/**
* Get extended image metadata, exif or iptc as available.
*
* Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
* created_timestamp, focal_length, shutter_speed, and title.
*
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
* and time, caption, copyright, and title. Also includes FNumber, Model,
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
*
* @todo Try other exif libraries if available.
* @since 2.5.0
*
* @param string $file
* @return bool|array False on failure. Image metadata array on success.
*/
function wp_read_image_metadata($file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
// exif contains a bunch of data we'll probably never need formatted in ways
// that are difficult to use. We'll normalize it and just extract the fields
// that are likely to be useful. Fractions and numbers are converted to
// floats, dates to unix timestamps, and everything else to strings.
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
// read iptc first, since it might contain data not available in exif such
// as caption, description etc
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
// headline, "A brief synopsis of the caption."
if (!empty($iptc['2#105'][0])) {
$meta['title'] = trim($iptc['2#105'][0]);
} elseif (!empty($iptc['2#005'][0])) {
$meta['title'] = trim($iptc['2#005'][0]);
}
if (!empty($iptc['2#120'][0])) {
// description / legacy caption
$caption = trim($iptc['2#120'][0]);
if (empty($meta['title'])) {
// Assume the title is stored in 2:120 if it's short.
if (strlen($caption) < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
if (!empty($iptc['2#110'][0])) {
// credit
$meta['credit'] = trim($iptc['2#110'][0]);
} elseif (!empty($iptc['2#080'][0])) {
// creator / legacy byline
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = trim($iptc['2#116'][0]);
}
}
}
// fetch additional info from exif if available
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['Title'])) {
$meta['title'] = trim($exif['Title']);
}
if (!empty($exif['ImageDescription'])) {
if (empty($meta['title']) && strlen($exif['ImageDescription']) < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($exif['ImageDescription']);
if (!empty($exif['COMPUTED']['UserComment']) && trim($exif['COMPUTED']['UserComment']) != $meta['title']) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
} elseif (trim($exif['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (!empty($exif['Comments']) && trim($exif['Comments']) != $meta['title']) {
$meta['caption'] = trim($exif['Comments']);
}
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
if (!empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
//.........这里部分代码省略.........
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:101,代码来源:image.php
示例3: wp_read_image_metadata
//.........这里部分代码省略.........
// creator / legacy byline
$meta['credit'] = trim($iptc['2#080'][0]);
}
if (!empty($iptc['2#055'][0]) && !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = trim($iptc['2#116'][0]);
}
if (!empty($iptc['2#025'][0])) {
// keywords array
$meta['keywords'] = array_values($iptc['2#025']);
}
}
}
/**
* Filter the image types to check for exif data.
*
* @since 2.5.0
*
* @param array $image_types Image types to check for exif data.
*/
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['ImageDescription'])) {
mbstring_binary_safe_encoding();
$description_length = strlen($exif['ImageDescription']);
reset_mbstring_encoding();
if (empty($meta['title']) && $description_length < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($exif['ImageDescription']);
}
if (empty($meta['caption']) && !empty($exif['COMPUTED']['UserComment'])) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
if (empty($meta['caption'])) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (empty($meta['caption']) && !empty($exif['Comments'])) {
$meta['caption'] = trim($exif['Comments']);
}
if (empty($meta['credit'])) {
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
}
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']);
}
if (!empty($exif['Orientation'])) {
$meta['orientation'] = $exif['Orientation'];
}
}
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
}
}
foreach ($meta['keywords'] as $key => $keyword) {
if (!seems_utf8($keyword)) {
$meta['keywords'][$key] = utf8_encode($keyword);
}
}
$meta = wp_kses_post_deep($meta);
/**
* Filter the array of meta data read from an image's exif data.
*
* @since 2.5.0
* @since 4.4.0 The `$iptc` parameter was added.
*
* @param array $meta Image meta data.
* @param string $file Path to image file.
* @param int $sourceImageType Type of image.
* @param array $iptc IPTC data.
*/
return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc);
}
开发者ID:skinnard,项目名称:FTL-2,代码行数:101,代码来源:image.php
示例4: wp_read_image_metadata
/**
* Get extended image metadata, exif or iptc as available.
*
* Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
* created_timestamp, focal_length, shutter_speed, and title.
*
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
* and time, caption, copyright, and title. Also includes FNumber, Model,
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
*
* @todo Try other exif libraries if available.
* @since 2.5.0
*
* @param string $file
* @return bool|array False on failure. Image metadata array on success.
*/
function wp_read_image_metadata($file)
{
if (!file_exists($file)) {
return false;
}
list(, , $sourceImageType) = getimagesize($file);
// exif contains a bunch of data we'll probably never need formatted in ways
// that are difficult to use. We'll normalize it and just extract the fields
// that are likely to be useful. Fractions and numbers are converted to
// floats, dates to unix timestamps, and everything else to strings.
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
// read iptc first, since it might contain data not available in exif such
// as caption, description etc
if (is_callable('iptcparse')) {
getimagesize($file, $info);
if (!empty($info['APP13'])) {
$iptc = iptcparse($info['APP13']);
if (!empty($iptc['2#110'][0])) {
// credit
$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
} elseif (!empty($iptc['2#080'][0])) {
// byline
$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
}
if (!empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0])) {
// created date and time
$meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]);
}
if (!empty($iptc['2#120'][0])) {
// caption
$meta['caption'] = utf8_encode(trim($iptc['2#120'][0]));
}
if (!empty($iptc['2#116'][0])) {
// copyright
$meta['copyright'] = utf8_encode(trim($iptc['2#116'][0]));
}
if (!empty($iptc['2#005'][0])) {
// title
$meta['title'] = utf8_encode(trim($iptc['2#005'][0]));
}
}
}
// fetch additional info from exif if available
if (is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)))) {
$exif = @exif_read_data($file);
if (!empty($exif['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($exif['FNumber']), 2);
}
if (!empty($exif['Model'])) {
$meta['camera'] = trim($exif['Model']);
}
if (!empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
if (!empty($exif['FocalLength'])) {
$meta['focal_length'] = wp_exif_frac2dec($exif['FocalLength']);
}
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = $exif['ISOSpeedRatings'];
}
if (!empty($exif['ExposureTime'])) {
$meta['shutter_speed'] = wp_exif_frac2dec($exif['ExposureTime']);
}
}
return apply_filters('wp_read_image_metadata', $meta, $file, $sourceImageType);
}
开发者ID:bluedanbob,项目名称:wordpress,代码行数:82,代码来源:image.php
示例5: extract_metadata
function extract_metadata($remote_meta)
{
$meta = array('aperture' => 0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '');
$meta['title'] = $this->extract_meta_value($remote_meta, array('Headline', 'ObjectName'));
$caption = $this->extract_meta_value($remote_meta, array('Caption-Abstract'));
if (!empty($caption)) {
if (empty($meta['title'])) {
if (strlen($caption) < 80) {
$meta['title'] = $caption;
} else {
$meta['caption'] = $caption;
}
} elseif ($caption != $meta['title']) {
$meta['caption'] = $caption;
}
}
$meta['credit'] = $this->extract_meta_value($remote_meta, array('Artist', 'Author', 'Credit', 'By-line'));
if (!empty($remote_meta["DateCreated"]) and !empty($remote_meta["TimeCreated"])) {
// created date and time
$meta['created_timestamp'] = strtotime($remote_meta["DateCreated"] . ' ' . $remote_meta["TimeCreated"]);
}
$meta['copyright'] = $this->extract_meta_value($remote_meta, array('Copyright', 'CopyrightNotice'));
if (!empty($remote_meta['Title'])) {
$meta['title'] = trim($remote_meta['Title']);
}
if (!empty($remote_meta['ImageDescription'])) {
if (empty($meta['title']) && strlen($remote_meta['ImageDescription']) < 80) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim($remote_meta['ImageDescription']);
if (!empty($remote_meta['UserComment']) && trim($remote_meta['UserComment']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['UserComment']);
}
} elseif (trim($remote_meta['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['ImageDescription']);
}
} elseif (!empty($remote_meta['Comments']) && trim($remote_meta['Comments']) != $meta['title']) {
$meta['caption'] = trim($remote_meta['Comments']);
}
$meta['camera'] = $this->extract_meta_value($remote_meta, array('Model'));
if (!empty($remote_meta['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($remote_meta['DateTimeDigitized']);
}
$meta['iso'] = $this->extract_meta_value($remote_meta, array('ISO'), 0);
if (!empty($remote_meta['FNumber'])) {
$meta['aperture'] = round(wp_exif_frac2dec($remote_meta['FNumber']), 2);
}
if (!empty($remote_meta['FocalLength'])) {
$meta['focal_length'] = (string) wp_exif_frac2dec($remote_meta['FocalLength']);
}
if (!empty($remote_meta['ExposureTime'])) {
$meta['shutter_speed'] = (string) wp_exif_frac2dec($remote_meta['ExposureTime']);
}
return $meta;
foreach (array('title', 'caption', 'credit', 'copyright', 'camera', 'iso') as $key) {
if ($meta[$key] && !seems_utf8($meta[$key])) {
$meta[$key] = utf8_encode($meta[$key]);
}
}
}
开发者ID:vanbungkring,项目名称:24custom,代码行数:59,代码来源:cloudinary.php
示例6: wp_read_image_metadata
//.........这里部分代码省略.........
$meta['title'] = trim($exif['ImageDescription']);
if (empty($meta['caption']) && !empty($exif['COMPUTED']['UserComment']) && trim($exif['COMPUTED']['UserComment']) != $meta['title']) {
$meta['caption'] = trim($exif['COMPUTED']['UserComment']);
}
} elseif (empty($meta['caption']) && trim($exif['ImageDescription']) != $meta['title']) {
$meta['caption'] = trim($exif['ImageDescription']);
}
} elseif (empty($meta['caption']) && !empty($exif['Comments']) && trim($exif['Comments']) != $meta['title']) {
$meta['caption'] = trim($exif['Comments']);
}
// Credit
if (empty($meta['credit'])) {
if (!empty($exif['Artist'])) {
$meta['credit'] = trim($exif['Artist']);
} elseif (!empty($exif['Author'])) {
$meta['credit'] = trim($exif['Author']);
}
}
// Copyright
if (empty($meta['copyright']) && !empty($exif['Copyright'])) {
$meta['copyright'] = trim($exif['Copyright']);
}
// Camera Make
if (!empty($exif['Make'])) {
$meta['make'] = $exif['Make'];
}
// Camera Model
if (!empty($exif['Model'])) {
$meta['model'] = trim($exif['Model']);
}
// Exposure Time (shutter speed)
if (!empty($exif['ExposureTime'])) {
$meta['exposure'] = $exif['ExposureTime'] . 's';
$meta['shutter_speed'] = (string) wp_exif_frac2dec($exif['ExposureTime']) . 's';
}
// Aperture
if (!empty($exif['COMPUTED']['ApertureFNumber'])) {
$meta['aperture'] = $exif['COMPUTED']['ApertureFNumber'];
} elseif (!empty($exif['FNumber'])) {
$meta['aperture'] = 'f/' . (string) round(wp_exif_frac2dec($exif['FNumber']), 2);
}
// ISO
if (!empty($exif['ISOSpeedRatings'])) {
$meta['iso'] = is_array($exif['ISOSpeedRatings']) ? reset($exif['ISOSpeedRatings']) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim($meta['iso']);
}
// Date
if (!empty($exif['DateTime'])) {
$meta['date'] = $exif['DateTime'];
}
// Created TimeStamp
if (empty($meta['created_timestamp']) && !empty($exif['DateTimeDigitized'])) {
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']);
}
// Lens
if (!empty($exif['UndefinedTag:0xA434'])) {
$meta['lens'] = $exif['UndefinedTag:0xA434'];
}
// Focus Distance
if (!empty($exif['COMPUTED']['FocusDistance'])) {
$meta['distance'] = $exif['COMPUTED']['FocusDistance'];
}
// Focal Length
if (!empty($exif['FocalLength'])) {
$meta['focallength'] = (string) round(wp_exif_frac2dec($exif['FocalLength'])) . 'mm';
}
开发者ID:pasyuk,项目名称:grand-media,代码行数:67,代码来源:core.php
示例7: saveAttachmentFields
/**
* Update EXIF fields.
*
* @param array $post The post data
* @param array $attachment Attachment fields from the $_POST form
* @return array $post Modified post data
*/
public function saveAttachmentFields($post, $attachment)
{
// Check if this is actually an image.
// bail if not
if (!wp_attachment_is_image($post['ID'])) {
return $post;
}
//First read the current attachment metadata
$meta_data = wp_get_attachment_metadata($post['ID']);
foreach ($this->fields as $fieldName => $value) {
//check existence just to be sure
//WordPress will create empty entries even if the EXIF entry in not present in the image EXIF metadata
if (isset($attachment[$this->prefix . $fieldName])) {
//depending on each field do what WordPress does to them - a sort of normalization
switch ($fieldName) {
case 'aperture':
$meta_data['image_meta'][$fieldName] = round(wp_exif_frac2dec($attachment[$this->prefix . $fieldName]), 2);
break;
case 'focal_length':
case 'shutter_speed':
$meta_data['image_meta'][$fieldName] = (string) wp_exif_frac2dec($attachment[$this->prefix . $fieldName]);
break;
default:
$meta_data['image_meta'][$fieldName] = trim($attachment[$this->prefix . $fieldName]);
}
}
}
//save the modified EXIF data into the database
wp_update_attachment_metadata($post['ID'], $meta_data);
return $post;
}
开发者ID:pixelgrade,项目名称:pixexif,代码行数:38,代码来源:class-pixexif.php
注:本文中的wp_exif_frac2dec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论