WordPress.org

Ready to get started?Download WordPress

Forums

Theme using full size image as opposed to a thumbnail (1 post)

  1. fembatty
    Member
    Posted 1 year ago #

    I am using a theme which is calling the full size images and then just limiting their size, which means for large images its taking forever to load. This is in the theme file

    <?php
    					if(have_posts()) {
    
    							 while (have_posts()) {
    								the_post(); 
    
    								$t = get_the_title();
    								$title_limit=substr($t, 0, 25);
    								$permalink=get_permalink();
    								$icon='';
    								$title='<a href="'.$permalink.'" title="'.get_the_title().'">'.$title_limit.'</a>';
    								$readmore='<span class="more-link" href="'.get_permalink().'"> […]</span>';
    								if($post->post_content != "" && $post->post_excerpt != ""){
    									$excerpt= $post->post_excerpt;
    									$description= substr($excerpt, 0, 30);
    								}
    								else if($post->post_content != "" && $post->post_excerpt == ""){
    									$excerpt= $post->post_content;
    									$description= substr($excerpt, 0, 30);
    								}
    								else{
    									$excerpt= get_the_excerpt();
    									$description= substr($excerpt, 0, 30);
    								}
    
    								//$excerpt= string_limit_words($description,50);
    								//insert the description in the lightbox if descriptions are disabled
    								$top=$imgHeight/2;
    								$left= $imgWidth/2;
    								$thumbnail= wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
    								//get the image title
    								$data = explode('/', $thumbnail);
    								$image_title=explode(".jpg", $data[8]);
    
    								if ( get_post_meta($post->ID, 'lightbox', true)){
    										$icon='gallery-video';
    										$openLink='<span class="portfolio_image"> ';
    										$closeLink='</span>';
    										$span_icon='<div id="icon" style="display:none;"><h4><a href="'.$permalink.'"><h4>'.$t.'</a></h4></div>';
    
    								}else{
    								$icon='gallery-image';
    								$openLink='<span class="portfolio_image">';
    								$closeLink='</span>';
    								$span_icon='<div id="icon" style="display:none;"><h4><a href="'.$permalink.'">'.$t.'</a></h4></div>';
    								}
    								$terms=wp_get_post_terms($post->ID, 'portfolio_category');
    								$term_string='';
    									foreach($terms as $term){
    										$term_string.=($term->name).',';
    									}
    								$term_string=substr($term_string, 0, strlen($term_string)-1);
    								$samp=str_replace(" ","-",$term_string);
    								$string = str_replace(","," ",$samp);
    								$finale= $string." ".$page;	
    
    								//generate the final item HTML
    					$html.= '<div class="element element'.$column.' '.$finale.'" data-filter="'.$finale.'">'.$openLink.''.$span_icon.'<img src="'.$thumbnail.'" width="'.$imgWidth.'" height="auto" title="'.get_the_title().'"/>'.$closeLink.'</div>';
    				}
    						}
    			echo $html;;
    		?>


    [Please use the code buttons when posting code here - as is your code may have been damaged]

    I have set an imagesize called "mythumb" up of the size I want in the image file - but every change I have tried to make to the above has failed. Can someone help?

Topic Closed

This topic has been closed to new replies.

About this Topic