Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1155641
    neodjandre
    Participant

    Hi,

    I have noticed that my search results contain the full size of the image I upload to a post, which make them very slow to load.

    How could I make it display a smaller image size?

    From my understanding, the theme already creates smaller scaled versions of the images I upload (?).

    many thanks for your help!

    #1155673
    neodjandre
    Participant

    On another note, I think the search results are showing the size of the featured image in the post.

    So I will look into this myself on how to adjust featured images because i am using ACF. thanks anyway!

    #1155735
    Nabeel A
    Moderator

    Hi there,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1191199
    neodjandre
    Participant
    This reply has been marked as private.
    #1191496
    Darshana
    Moderator

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1191516
    neodjandre
    Participant
    This reply has been marked as private.
    #1191823
    Lely
    Moderator

    Hi There,

    Thank you for the credentials. To use cropped version of featured image on search page, please add the following code on your child theme’s functions.php file:

      function x_featured_image( $cropped = '' ) {
    
        $stack     = x_get_stack();
        $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
    
        if ( has_post_thumbnail() ) {
    
          if ( $cropped == 'cropped' ) {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
            }
          } else {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
            }
          }
    
          switch ( is_singular() ) {
            case true:
              printf( '<div class="entry-thumb">%s</div>', $thumb );
              break;
            case false:
    		  if(is_search()){
    					$thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
    	
    			  printf( 'YENG<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
    				esc_url( get_permalink() ),
    				esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
    				$thumb
    			  );
    		  }else{
    
              printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
    		  }
              break;
          }
    
        }
    
      }

    Hope this helps.

    #1192417
    neodjandre
    Participant

    Hi,

    This is taking the image with with width 862px which is still too much. I would rather take the cropped image with width 300px.

    Also I suppose the text “YENG” in your code is for testing purposes ?

    #1192490
    Thai
    Moderator

    Hi There,

    Please update the previous code to this:

    function x_featured_image( $cropped = '' ) {
    	$stack     = x_get_stack();
    	$fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
    
    	if ( has_post_thumbnail() ) {
    
    	  if ( $cropped == 'cropped' ) {
    	    if ( $fullwidth ) {
    	      $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
    	    } else {
    	      $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
    	    }
    	  } else {
    	    if ( $fullwidth ) {
    	      $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
    	    } else {
    	      $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
    	    }
    	  }
    
    	  switch ( is_singular() ) {
    	    case true:
    	      printf( '<div class="entry-thumb">%s</div>', $thumb );
    	      break;
    	    case false:
    		  if(is_search()){
    					$thumb = get_the_post_thumbnail( NULL, 'medium', NULL );
    
    			  printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
    				esc_url( get_permalink() ),
    				esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
    				$thumb
    			  );
    		  }else{
    
    	      printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
    	        esc_url( get_permalink() ),
    	        esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
    	        $thumb
    	      );
    		  }
    	      break;
    	  }
    
    	}
    }

    Hope it helps 🙂

    #1192550
    neodjandre
    Participant

    yes thank you 🙂

    #1192571
    Thai
    Moderator

    You’re most welcome 🙂

  • <script> jQuery(function($){ $("#no-reply-1155641 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>