我需要改变这一行
$image = vt_resize( '', $f_image, 420, 280, true );
到新维度,但我不知道如何正确地将它放入我的孩子主题functions.php
。
我根本无法找到执行此操作的代码。
if ( !function_exists( 'get_post_media' ) )
{
function get_post_media()
{
$image = '';
if ( is_single() )
{
if ( has_post_thumbnail() )
{
$thumb = get_post_thumbnail_id();
$f_image = wp_get_attachment_url( $thumb );
$alt = get_post_meta( $thumb, '_wp_attachment_image_alt', true );
$title = get_the_title( $thumb );
if ( $f_image )
{
if ( zget_option( 'sb_use_full_image', 'blog_options', false, 'no' ) == 'yes' )
{
$featured_image = wp_get_attachment_image_src( $thumb, 'full' );
if ( isset( $featured_image[ 0 ] ) && !empty( $featured_image[ 0 ] ) )
{
$image = '<a data-lightbox="image" href="' . $featured_image[ 0 ] . '" class="hoverBorder pull-left full-width kl-blog-post-img"><img src="' . $featured_image[ 0 ] . '" ' . ZngetImageSizesFromUrl( $featured_image[ 0 ], true ) . ' alt="' . ZngetImageAltFromUrl( $featured_image[ 0 ] ) . '" title="' . ZngetImageTitleFromUrl( $featured_image[ 0 ] ) . '"/></a>';
}
}
else
{
$feature_image = wp_get_attachment_url( $thumb );
$image = vt_resize( '', $f_image, 420, 280, true );
$image = '<a data-lightbox="image" href="' . $feature_image . '" class="hoverBorder pull-left kl-blog-post-img kl-blog-post--default-view" ><img src="' . $image[ 'url' ] . '" width="' . $image[ 'width' ] . '" height="' . $image[ 'height' ] . '" alt="' . $alt . '" title="' . $title . '"/></a>';
}
}
}
}
}
}
答案 0 :(得分:0)
此代码将强制该功能始终使用您的全尺寸图像。但是,最好在仪表板中设置主题选项以强制使用完整尺寸的图像。
if ( !function_exists( 'get_post_media' ) ) {
function get_post_media()
{
$image = '';
if ( is_single() )
{
if ( has_post_thumbnail() )
{
$thumb = get_post_thumbnail_id();
$f_image = wp_get_attachment_url( $thumb );
$alt = get_post_meta( $thumb, '_wp_attachment_image_alt', true );
$title = get_the_title( $thumb );
if ( $f_image )
{
$featured_image = wp_get_attachment_image_src( $thumb, 'full' );
if ( isset( $featured_image[ 0 ] ) && !empty( $featured_image[ 0 ] ) )
{
$image = '<a data-lightbox="image" href="' . $featured_image[ 0 ] .
'" class="hoverBorder pull-left full-width kl-blog-post-img"><img src="' .
$featured_image[ 0 ] . '" ' . ZngetImageSizesFromUrl( $featured_image[ 0 ], true ) . ' alt="' . ZngetImageAltFromUrl( $featured_image[ 0 ] ) .
'" title="' . ZngetImageTitleFromUrl( $featured_image[ 0 ] ) . '"/></a>';
}
}
}
}
}
}