本文整理汇总了PHP中ImageHelper::IGetDimension方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageHelper::IGetDimension方法的具体用法?PHP ImageHelper::IGetDimension怎么用?PHP ImageHelper::IGetDimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageHelper
的用法示例。
在下文中一共展示了ImageHelper::IGetDimension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IPrepare
/**
*
*/
public static function IPrepare($imgs, $posts, $meta_checkout = array(), $forceScan = false)
{
$iNotGood = array();
$iNotGoodTotal = array();
$metaNotGood = array();
$metaNotGoodTotal = array();
$upload_dir = wp_upload_dir();
foreach ($posts as $post) {
if (empty($post->post_content)) {
continue;
}
$ifound = self::IScan($imgs, $post->post_content);
if (count($ifound) < 1) {
continue;
}
foreach ($ifound as $order => $img) {
$iID = $img['id'];
//Get image that its size is not good
if (!(list($width_origin, $height_origin) = @getimagesize($img['src']))) {
continue;
}
$ratio_origin = $width_origin / $height_origin;
$width = $img['width'];
$height = $img['height'];
//Check if img tag is missing with/height attribute value or not
if (!$width && !$height) {
$width = $width_origin;
$height = $height_origin;
} elseif ($width && !$height) {
$height = $width * (1 / $ratio_origin);
} elseif ($height && !$width) {
$width = $height * $ratio_origin;
}
if ($width_origin > $width || $height_origin > $height) {
$img_before = str_replace(array($upload_dir['baseurl']), '', $img['src']);
$ibpart = ImageHelper::IGetPart($img_before);
$img_after = $ibpart->base_path . (!empty($ibpart->name_prefix) ? $ibpart->name_prefix : $ibpart->name) . '-' . $width . 'x' . $height . $ibpart->name_suffix . $ibpart->ext;
$destination = $upload_dir['basedir'] . '/' . $img_after;
$srcs = array('img_before_dir' => $upload_dir['basedir'] . $img_before, 'img_before_url' => $upload_dir['baseurl'] . $img_before, 'img_after_dir' => $upload_dir['basedir'] . $img_after, 'img_after_url' => $upload_dir['baseurl'] . $img_after);
$size = filesize($srcs['img_before_dir']) / 1024;
if ($size > 1024) {
$size = $size / 1024;
$sizes = 'MB';
} else {
$sizes = 'KB';
}
$size = @round($size, 1);
$iNotGood[$iID][$post->ID]['ID'] = $post->ID;
$iNotGood[$iID][$post->ID]['title'] = $post->post_title;
$iNotGood[$iID][$post->ID]['post_type'] = $post->post_type;
$iNotGood[$iID][$post->ID]['img_before_optm'][$order] = array('size' => $size, 'sizes' => $sizes, 'src' => $srcs['img_before_url'], 'width' => $width, 'height' => $height, 'dimension' => ImageHelper::IGetDimension($img_before));
$iNotGood[$iID][$post->ID]['img_after_optm'][$order] = array('size' => 0, 'path' => $img_after, 'src' => $srcs['img_after_url'], 'src_origin' => $srcs['img_before_url'], 'width' => $width, 'height' => $height, 'dimension' => ImageHelper::IGetDimension($img_after));
//Get the number of images which their size are not good
if (!isset($iNotGoodTotal[$iID])) {
$iNotGoodTotal[$iID] = 0;
}
$iNotGoodTotal[$iID]++;
} else {
if (!isset($iNotGood[$iID])) {
$iNotGood[$iID] = array();
}
if (!isset($iNotGoodTotal[$iID])) {
$iNotGoodTotal[$iID] = 0;
}
}
//Get image that its meta/metas is/are not good
if (count($meta_checkout) > 0) {
foreach ($meta_checkout as $key => $meta) {
$meta_value = $img[$meta];
$imNotGood[$iID][$post->ID]['ID'] = $post->ID;
$imNotGood[$iID][$post->ID]['title'] = $post->post_title;
$imNotGood[$iID][$post->ID]['post_type'] = $post->post_type;
$imNotGood[$iID][$post->ID]['meta'][$order]['img_src'] = $img['src'];
$imNotGood[$iID][$post->ID]['meta'][$order]['type'][$meta] = $meta_value;
#if($forceScan !== TRUE && $meta_value != ''){
#unset($_posts['meta_not_good'][$img_post_id][$post->ID]['meta'][$order]['type'][$meta]);
#}
if ($meta_value == '') {
if (!isset($imNotGoodTotal[$iID][$meta])) {
$imNotGoodTotal[$iID][$meta] = 0;
}
$imNotGoodTotal[$iID][$meta]++;
}
}
}
}
}
foreach ($imgs as $name => $iID) {
if (!isset($iNotGoodTotal[$iID])) {
$iNotGoodTotal[$iID] = -1;
}
if (!isset($iNotGood[$iID])) {
$iNotGood[$iID] = array();
}
if (!isset($imNotGood[$iID])) {
$imNotGood[$iID] = array();
}
//.........这里部分代码省略.........