我正在使用此自定义函数在图像上显示图像大小。php(附件页)
function my_get_image_size_links() {
/* If not viewing an image attachment page, return. */
if ( !wp_attachment_is_image( get_the_ID() ) )
return;
/* Set up an empty array for the links. */
$links = array();
/* Get the intermediate image sizes and add the full size to the array. */
$sizes = get_intermediate_image_sizes();
$sizes[] = \'full\';
/* Loop through each of the image sizes. */
foreach ( $sizes as $size ) {
/* Get the image source, width, height, and whether it\'s intermediate. */
$image = wp_get_attachment_image_src( get_the_ID(), $size );
/* Add the link to the array if there\'s an image and if $is_intermediate (4th array value) is true or full size. */
if ( !empty( $image ) && ( true == $image[3] || \'full\' == $size ) )
$links[] = "<a class=\'image-size-link\' href=\'{$image[0]}\' target=_blank>{$image[1]} × {$image[2]}</a>";
}
/* Join the links in a string and return. */
return join( \' <span class="sep">/</span> \', $links );
}
在附件页面上,当我单击图像大小(如1602×1200/1920×1437/1442×1080/150×150/2580×1932)时,它将打开图像,例如站点。com/wp-content/uploads/2014/10/randomage-1602×1200。jpg公司
但不是打开网站。com/wp-content/uploads/2014/10/randomage-1602×1200。jpg直接,我希望它打开一个页面,在那里的图像大小将被张贴。
有人知道怎么做吗?
非常感谢。
最合适的回答,由SO网友:vyperlook 整理而成
好的,我发现答案(实际上是付钱给程序员的)修改为
/* Add the link to the array if there\'s an image and if $is_intermediate (4th array value) is true or full size. */
if ( !empty( $image ) && ( true == $image[3] || \'full\' == $size ) )
$links[] = "<a class=\'image-size-link\' href=\'/show-image.php?path={$image[0]}\' target=_blank>{$image[1]} × {$image[2]}</a>";
}
创建一个文件,将其上载到根目录中(或您想要的位置),并在其中添加以下代码:
“/>希望这有帮助!