我想主题,以获取在张贴区的第一个图像URL,并显示为特色图像它。这是来自旧的附属公司WordPress主题functions.php
文件这家公司已经倒闭了。
这是我正在处理的代码:
function pixr_get_thumb( $post )
{
$wprobot = get_post_meta( $post->ID, "pixr_wpr_thumb", true );
$wpzon = get_post_meta( $post->ID, "amzn_MediumImageURL", true );
$goliath = get_post_meta( $post->ID, "amazon-image-url", true );
$reviewazon = get_post_meta( $post->ID, "ReviewAZON_MediumImage", true );
$amaniche = get_post_meta( $post->ID, "product_image", true );
if ( has_post_thumbnail( ) )
{
$image_id = get_post_thumbnail_id( );
$image_url = wp_get_attachment_image_src( $image_id, "blog-thumb", true );
$image_url = $image_url[0];
}
$manual = $image_url;
$pixrdefault = get_post_meta( $post->ID, "pixr_thumb", true );
$nothumb = get_bloginfo( "template_directory" )."/assets/img/nothumb.png";
if ( $wprobot )
{
$thumb = $wprobot;
}
else if ( $wpzon )
{
$thumb = $wpzon;
}
else if ( $goliath )
{
$thumb = $goliath;
}
else if ( $reviewazon )
{
$thumb = $reviewazon;
}
else if ( $amaniche )
{
$thumb = $amaniche;
}
else if ( $manual )
{
$thumb = $manual;
}
else if ( $pixrdefault )
{
$thumb = $pixrdefault;
}
else
{
$thumb = $nothumb;
}
return $thumb;
}
function pixr_azon_thumb( )
{
global $post;
$thumb = pixr_get_thumb( $post );
echo $thumb;
}
function pixr_get_image( $post )
{
$wprobot = get_post_meta( $post->ID, "pixr_wpr_image", true );
$wpzon = get_post_meta( $post->ID, "amzn_LargeImageURL", true );
$goliath = get_post_meta( $post->ID, "amazon-image-url-large", true );
$reviewazon = get_post_meta( $post->ID, "ReviewAZON_LargeImage", true );
$amaniche = get_post_meta( $post->ID, "image_large_1", true );
if ( has_post_thumbnail( ) )
{
$image_id = get_post_thumbnail_id( );
$image_url = wp_get_attachment_image_src( $image_id, "product-large", true );
$image_url = $image_url[0];
}
$manual = $image_url;
$pixrdefault = get_post_meta( $post->ID, "pixr_image", true );
$nothumb = get_bloginfo( "template_directory" )."/assets/img/nothumb.png";
if ( $wprobot )
{
$image = $wprobot;
}
else if ( $wpzon )
{
$image = $wpzon;
}
else if ( $goliath )
{
$image = $goliath;
}
else if ( $reviewazon )
{
$image = $reviewazon;
}
else if ( $amaniche )
{
$image = $amaniche;
}
else if ( $manual )
{
$image = $manual;
}
else if ( $pixrdefault )
{
$image = $pixrdefault;
}
else
{
$image = $nothumb;
}
return $image;
}