1

私のサイト - http://www.sweetrubycakes.com.au - では最近、サムネイルが機能しなくなりました (昨日まで機能していましたが、昨日はドメイン レジストラーに問題がありましたが、それ以外の原因は何もわかっていません)。 )。

ソースを表示すると、URL に含まれているものが多すぎることがわかります。

<img src="/home2/sweetrub/public_html/wp-content/uploads/et_temp/t-rex-tiny-63339_203x203.jpg" class="item-image" alt="T- Rexcellent">

どこにあるべきか:

<img src="/wp-content/uploads/et_temp/t-rex-tiny-63339_203x203.jpg" class="item-image" alt="T- Rexcellent">

テーマの最新バージョンを使用しているとは思いませんが、微調整を行ったので更新したくありません。

その画像を出力するコードは次のとおりです。

<?php
   $work_count = 0;
   $recent_work_args = apply_filters( 'evolution_recent_work_args', array(
      'showposts' => (int) get_option('evolution_posts_work_num'),
      'category__not_in' => (array) get_option('evolution_exlcats_work')
   ) );
   $recent_work_query = new WP_Query( $recent_work_args );
   while ( $recent_work_query->have_posts() ) : $recent_work_query->the_post();
      ++$work_count;
      $width = apply_filters( 'evolution_home_work_width', 203 );
      $height = apply_filters( 'evolution_home_work_height', 203 );
      $titletext = get_the_title();
      $thumbnail = get_thumbnail($width,$height,'item-image',$titletext,$titletext,true,'Work');
      $thumb = $thumbnail["thumb"];
      $lightbox_title = ( $work_title = get_post_meta($post->ID, 'work_title',true) ) ? $work_title : $titletext;
      $work_description = ( $work_desc = get_post_meta($post->ID, 'work_description',true) ) ? $work_desc : truncate_post( 50, false );
?>
      <div class="r-work<?php if ( 0 == $work_count % 3 ) echo ' last'; ?>">
         <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, 'item-image'); ?>
         <span class="overlay"></span>
         <!--<a href="<?php the_permalink(); ?>" class="more"></a>-->
         <a href="<?php echo esc_url($thumbnail['fullpath']); ?>" class="zoom fancybox" title="<?php echo esc_attr( $lightbox_title ); ?>" rel="work_gallery" style="right: 77px !important;"></a>
         <p><?php echo esc_html( $work_description ); ?></p>
      </div> <!-- end .r-work -->
<?php endwhile; wp_reset_postdata(); ?>

print_thumbnail 関数は次のようになります。

if ( ! function_exists( 'print_thumbnail' ) ){
function print_thumbnail($thumbnail = '', $use_timthumb = true, $alttext = '', $width = 100, $height = 100, $class = '', $echoout = true, $forstyle = false, $resize = true, $post='') {
    global $shortname;
    if ( $post == '' ) global $post;

    $output = '';
    $thumbnail_orig = $thumbnail;

    $thumbnail = et_multisite_thumbnail( $thumbnail );

    $cropPosition = '';

    $allow_new_thumb_method = false;

    $new_method = true;
    $new_method_thumb = '';
    $external_source = false;

    $allow_new_thumb_method = !$external_source && $new_method && $cropPosition == '';

    if ( $allow_new_thumb_method && $thumbnail <> '' ){
        $et_crop = get_post_meta( $post->ID, 'et_nocrop', true ) == '' ? true : false; 
        $new_method_thumb =  et_resize_image( et_path_reltoabs($thumbnail), $width, $height, $et_crop );
        if ( is_wp_error( $new_method_thumb ) ) $new_method_thumb = '';
    }

    if ($forstyle === false) {
        $output = '<img src="' . esc_url( $new_method_thumb ) . '"';

        if ($class <> '') $output .= " class='" . esc_attr( $class ) . "' ";

        $output .= " alt='" . esc_attr( strip_tags( $alttext ) ) . "' />";

        if (!$resize) $output = $thumbnail;
    } else {
        $output = $new_method_thumb;
    }

    if ($echoout) echo $output;
    else return $output;
}

}

ファイルのアクセス許可フォルダー ( wp print_thumbnail function is not working )であることを示唆する他の投稿を見てきましたが、それは私にとっては機能していないようです。

誰か提案はありますか?

4

1 に答える 1

0

print_thumbnailあなたのコードの問題だと思います。print_thumbnail以下のオプションを試す代わりに。

<?php
if ( has_post_thumbnail() ) {
    the_post_thumbnail(); // Outputs <img/> object with src="thumbnail-href"
}
?>

同様に、これも機能します。

<?php
if ( has_post_thumbnail() ) {
    echo( get_the_post_thumbnail( get_the_ID() ) );
}
?>

このスタックオーバーフローの回答を確認してください

于 2012-06-19T12:58:23.423 に答える