• 04-09-2009, 22:33:53
    #1
    Merhaba arkadaşlar,
    Wordpress sitemde tumbnail sorunu var ne yaptıysam olmadı. Önce timthumb.php yi kullanarak küçük resim çekmeye çalıştım olmadı sonra phpthumb'u indirdim gene olmadı.
    Kodlar aşağıdadır:
    Bu thumbnail resim almak için gereken foksiyon:
     <?php  
    function show_thumb($width,$height) {
    	global $post;
    	$custom_field_value = get_post_meta($post->ID, 'thumbnail', true);
    	$attachments = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'numberposts' => 1) );
    	if ($attachments == true) {
    	foreach($attachments as $id => $attachment) {
    	$img = wp_get_attachment_image_src($id, 'full');
    	$tweak = str_replace('/', '%2F', $img[0]);
    	$img_url = str_replace(':', '%3A', $tweak);
    	print '<a href="'.get_permalink($post).'" title="'.$post->post_title.'"><img src="'.get_template_directory_uri().'/scripts/phpThumb/phpThumb.php?src='.$img_url.'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=T&amp;q=95" title="'.$post->post_title.'" alt="'.$post->post_title.'" /></a>';
    	}
    	} elseif ( $custom_field_value == true) {
    	$tweak = str_replace('/', '%2F', $custom_field_value);
    	$img_url = str_replace(':', '%3A', $tweak);
    	print '<a href="'.get_permalink($post).'" title="'.$post->post_title.'"><img src="'.get_template_directory_uri().'/scripts/phpThumb/phpThumb.php?src='.$img_url.'&amp;w='.$width.'&amp;h='.$height.'&amp;zc=T&amp;q=95" title="'.$post->post_title.'" alt="'.$post->post_title.'" /></a>';
    	} else {
    	// Boş olacak
    	}
    }  
     ?>
    Burda da fonksiyonu çağırarak 180,130 ebadında resim çekmek istiyoruz
    <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    			<?php   show_thumb(180,130); ?>	
    		<?php endif; ?>
    Sizce hata nerde. 2 gündür uğraşıyorum
  • 04-09-2009, 22:40:35
    #2
    thumbnail kullanan bir temayı bence aç incele en güzel ve en çabk ulaşırsın.
  • 04-09-2009, 22:43:23
    #3
    Alıntı
    <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    <img src="<?php $values = get_post_custom_values("thumbnail"); echo $values[0]; ?>" alt="<?php the_title(); ?>" />
    <?php else: ?>
    <?php endif; ?>
    <?php else: ?> kodunu eklemedğinizden olabilir..
  • 04-09-2009, 22:58:06
    #4
    eshkidadlieric adlı üyeden alıntı: mesajı görüntüle
    <?php else: ?> kodunu eklemedğinizden olabilir..
    Onuda ekledim olmadı ama garip bi şey oldu.
    <?php else:?><?php echo "<img src='herhangibirresim.jpg'";?>
    şeklinde yaptım. Fonksiyonun else bölümü çalıştı. Yani manuel olarak url sini eklediğim resim basıldı. Fonksiyon mu yanlış ondan mı direk else bölümüne geçiyor anlamadım. Belki 1000 defa kontrol ettim foksiyonu herhangi bir şey bulamadım. Neden else bölümüne geçiyor anlaamdım.