WordPress küçük boyutu görüntüleri boyutlandırma

0 Cevap php

Benim ilk WordPress Tema inşa ediyorum ve bir şey şaşırıp.

Ben her yazının yüklendiği ilk görüntü kapmak ve blog arşiv sayfasında koyar get_first_photo () olarak adlandırılan benim functions.php bir işlevi var. Bu güzel çalışıyor, ancak tam boyutlu görüntü yükler ve CSS kullanarak yeniden boyutlandırır. O yüzden görüntü boyutu yükü yoktur WP kontrol panelinde ayarlanmış küçük boyutu bulunuyor azından ben daha çok görüntü yüklemek istiyorsunuz. Bunu gerçekleştirmek için herhangi bir şekilde?

İşte functions.php gelen kodu:

function get_first_photo($id) {
    global $wpdb;
    return $wpdb->get_var("SELECT guid FROM wp_posts WHERE post_parent = $id AND post_mime_type = 'image/jpeg' ORDER BY id DESC LIMIT 1");  
}

Ve burada blog şablon var:

<?php

get_header(); ?>
<div id="content" class="blog">
    <div id="body">
        <h3 class="title" id="blog">The Ned Leary Blog</h3>
<?php if (have_posts()) : 
query_posts("category_name=blog");
while (have_posts()) : 
the_post(); 
$first_photo = get_first_photo(get_the_ID());
?>
        <div class="snippet">
<?php if (!empty($first_photo)) : ?>
            <img src="<?php echo $first_photo; ?>" alt="Thumbnail" />
<?php else : ?>
            <img src="<?php bloginfo('url'); ?>/images/blog/gravatarBig.jpg" alt="Ned Leary Gravatar" />
<?php endif; ?>
            <div class="details">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <h5><?php the_time('D, M j, Y') ?> by <?php the_author('') ?> | <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></h5>
                <?php the_excerpt(); ?>
                <h4><a href="<?php the_permalink(); ?>">Read more&hellip;</a></h4>
            </div>
        </div><!--end snippet-->
<?php endwhile; endif;// end of the loop. ?>
    </div><!--end body-->
<?php get_sidebar(); ?>
</div><!--end content-->
<?php get_footer(); ?>

0 Cevap