由称为动态特色图像的插件提供的中等尺寸图像 [英] Medium size image by plugin called dynamic featured image
问题描述
我正在使用动态特色图片并将多个产品图片添加到单个自定义帖子类型名称中作为单个产品的产品,但我试图在我的模板中获取这些图片,但数组只返回两种尺寸 [拇指] [完整]但我也需要中等以下是我的代码
get_featured_images();foreach($featured_images 作为 $featured_image) {?><a href="<?php echo $featured_image['full'];?>"rel="rings" rev="<?php echo $featured_image['medium'];?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a><?php }}?>
正如你们在锚标签 $featured_image['medium'] 中看到的,这就是我想要回应这个锚标签的方式,但不幸的是它没有返回给我中等尺寸,我需要帮助来获得中等尺寸好.下面是我得到的数组,你只能清楚地看到 [thumb] 和 [full].请帮忙
数组([拇指] =>http://www.example.com/wp-content/uploads/2014/07/product-1-120x90.jpg[完整] =>http://www.example.com/wp-content/uploads/2014/07/product-1.jpg[attachment_id] =>254)
您需要通过调用 get_image_url
函数来获取中等大小的图像.试试这个:
get_featured_images();foreach($featured_images 作为 $featured_image) {$mediumSizedImage = $dynamic_featured_image->get_image_url($featured_image['attachment_id'], 'medium');echo "<img src = '" .$mediumSizeImage ."'/>";?><a href="<?php echo $featured_image['full'];?>"rel="rings" rev="<?php echo $mediumSizedImage ?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a><?php }}?>
此处记录了所有可用函数.>
PS:我是插件的作者.
i am using dynamic featured image and adding multiple product images to a single custom post type name as products for a single product but and i am trying to get those images in my template but the array only return me only two sizes [thumb] [full] but i need medium as well below is my code
<?php
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$featured_images = $dynamic_featured_image->get_featured_images();
foreach($featured_images as $featured_image) {
?>
<a href="<?php echo $featured_image['full'];?>" rel="rings" rev="<?php echo $featured_image['medium'];?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a>
<?php }
}
?>
As you guys can see in the anchor tag $featured_image['medium'] this is how i want to echo this anchor tag but unfortunately it don't return me the medium size and i need help in getting the medium size as well. below is the array that i get where you can clearly see only [thumb] and [full]. please help
Array
(
[thumb] => http://www.example.com/wp-content/uploads/2014/07/product-1-120x90.jpg
[full] => http://www.example.com/wp-content/uploads/2014/07/product-1.jpg
[attachment_id] => 254
)
You need to get medium sized image by calling get_image_url
function. Try this:
<?php
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$featured_images = $dynamic_featured_image->get_featured_images();
foreach($featured_images as $featured_image) {
$mediumSizedImage = $dynamic_featured_image->get_image_url($featured_image['attachment_id'], 'medium');
echo "<img src = '" . $mediumSizedImage . "' />";
?>
<a href="<?php echo $featured_image['full'];?>" rel="rings" rev="<?php echo $mediumSizedImage ?>"><img width="60" src="<?php echo $featured_image['full'];?>"/></a>
<?php }
}
?>
All available functions are documented here.
PS: I am author of the plugin.
这篇关于由称为动态特色图像的插件提供的中等尺寸图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!