2016-07-18 34 views
2

由于使用了放大镜脚本,我需要在文章中加载完整尺寸的图像,即使客户选择像大,中等缩略图尺寸... ..WordPress:在文章缩略图格式中加载全尺寸图像

我的意思不是后缩略图,我的意思是嵌入在帖子本身的图像。因此,相对于the_post_thumnail任何功能都没有这样的帮助我想... :-)

例...应该产生这样的代码:

<img src="..../uploads/image.png" width="300" height="500" /> 

,而不是

<img src="..../uploads/image-300x500.png" width="300" height="500" /> 

任何人有一个很酷的想法呢?谢谢!

+0

的可能的复制[WordPress的:加载最大尺寸的图像缩略图] (http://stackoverflow.com/questions/38300618/wordpress-load-full-size-image-in-thumbnail) –

+0

不能:-)你的意思是你的线程是post_thumbnails ... :-) – user6573193

回答

0

可以使用image_send_to_editor滤波器和服务由您构建的标记,在这里你展示完整的图像,就像下面的代码:

add_filter('image_send_to_editor', 'my_insert_image', 10, 9); 

function my_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt) { 
    list($img_src, $width, $height) = image_downsize($id, $size); 
    $hwstring = image_hwstring($width, $height); 
    $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id; 
    $img_src = wp_get_attachment_image_src($id, 'full'); 
    $html = '<img src="' . esc_attr($img_src[0]) . '" alt="' . esc_attr($alt) . '" ' . $title . $hwstring . 'class="' . $class . '" />'; 

    return $html; 
} 
相关问题