WordPress.org

Ready to get started?Download WordPress

Forums

Slow loading category pages - image attachment issue? (2 posts)

  1. ebedgert
    Member
    Posted 1 year ago #

    I'm using a theme which uses wp_get_attachment_image to implement the display of featured image and thumbnails on the category pages. (I have no use for the thumbnails, so I've edited out that part of the code.) I've noticed that having multiple posts in a category that have featured images attached to them, results in exponentially slow loading of the category page. I've confirmed this by removing all featured images from posts except for one post in each category, which results in a nearly normal load time for the pages.

    This seems like a really excessive delay. You should be able to have many posts in a given category which have an image attached to them, without it affecting the load time of your category page, right? Here is the code I'm looking at and I'm wondering if the theme I'm working with is using this the right way. Is there anything wrong here?

    <?php
    					while (have_posts()) {
    							the_post();
    					$img_description = '';
    					if(get_post_thumbnail_id($post -> ID) )
    					{
    
    						$post_img_big = wp_get_attachment_image(get_post_thumbnail_id($post -> ID),'featured_540x270','' );
    						$img_description = de_getPostImageDescription($post -> ID,get_post_thumbnail_id($post -> ID));
    					}
    					else
    					{
    						$post_img_big = get_first_image($post -> ID,'540x270');	
    
    					}
    		?>

    The image is printed this way:

    <div class="cat_content">
                  <?php echo $post_img_big; ?>
    						<h2><a href="<?php the_permalink(); ?>" class="link_inv"><?php echo $post -> post_title; ?></a></h2>

    ...etc.

  2. Steven Jones
    Member
    Posted 1 year ago #

    It doesn't look like it should be slowing anything down too much.

    Do you have a link?

Topic Closed

This topic has been closed to new replies.

About this Topic