これはバグですか?wp_get_attachment_imageが異なる画像サイズを返す
wp_get_attachment_image($attachment_id, 'post-thumb-size-small');
テンプレート内で呼び出され、AJAX呼び出しで呼び出される同じコードが同じ画像SRCを返しますが、画像の幅と高さは異なります。
テンプレート呼び出しからダンプ:
<img width="286" height="189" src="http://localhost/site/files/2012/02/post-image-31-286x189.jpg" class="attachment-post-thumb-size-small" alt="post-image-3" title="post-image-3">
ダンプAJAX呼び出し
<img width="220" height="145" src="http://localhost/site/files/2012/02/post-image-31-286x189.jpg" class="attachment-post-thumb-size-small" alt="post-image-3" title="post-image-3">
からいただきました間違った私は、混乱していますか?
index.phpをコード
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php include 'post.php'; ?>
<?php endwhile; endif; ?>
post.phpコード
<div class="container">
<?php
$theme->theme_post->display_post_element($post_type, $post_size, $post);
?>
</div>
display_post_element機能コードAJAX呼び出しコードで
function display_post_element($post_type, $post_size, $post) {
$attachment_id = get_post_meta($post->ID, '_view_attachment_id', true);
if($post_type == 'single_image') {
$img = wp_get_attachment_image_src($attachment_id, 'full');
if(is_array($img)):
?>
<div class="preview-thumb">
<a href="<?php echo $img[0]; ?>" class="lightbox"><?php echo wp_get_attachment_image($attachment_id, 'post-thumb-size-' . $post_size); ?></a>
<a href="<?php echo $img[0]; ?>" class="lightbox zoom"></a>
</div>
<?php
endif;
}
}
負荷ポスト:
function load_posts_ajax() {
global $post;
$query_string = $_POST['query_string'];
query_posts($query_string . '&posts_per_page=' . get_option('posts_per_page') . '&post_status=publish&offset=' . (int)$_POST[ 'off']);
if (have_posts()) : while (have_posts()) : the_post();
include TEMPLATEPATH . '/post.php';
endwhile; endif;
die;
}
テーマコンストラクタのfunctions.phpで画像サイズを定義しました。 私はget_intermediate_image_sizes()をダンプし、すべての画像サイズはAJAX呼び出しでロードされます
これはWP 4.0ではまだ問題です。私は正しいサイズが必要で、イメージで画像を表示できません。他の回避策を見つけましたか?ありがとう – Alvaro