Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1230514
    MB
    Participant

    Hi,

    I would like to use a smaller image ans my portfolio item feature image. Right now it’s pulling the full size image.

    Thanks, MB

    Vancouver Island Hiking Guide

    #1230929
    Lely
    Moderator

    Hi MB,

    Thanks for posting in.
    Please check this thread:https://community.theme.co/forums/topic/change-image-size-for-integrity-1-portfolio-pages/

    Hope this helps.

    #1231458
    MB
    Participant

    Added code provided in the thread to functions.php in my child theme and no change.

    #1231591
    Christian
    Moderator

    Hey MB,

    Please add the code below in your functions.php

      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:
              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;
          }
    
        }
    
      }

    Then, change the image size in the get_the_post_thumbnail function like

    get_the_post_thumbnail( NULL, 'medium', NULL );

    For more details about that function, please see https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

    Thanks.

    #1231607
    MB
    Participant

    Ok thanks, I have that code placed in there, but I want the entry image in there. 895×9999

    #1232279
    Rad
    Moderator

    Hi there,

    Instead of changing all image size, you can change this part

            case false:
              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;
          }

    to this

            case false:
              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' ) ) ),
                get_the_post_thumbnail( NULL, 'medium', NULL )
              );
              break;
          }

    Hope this helps.

    #1233786
    MB
    Participant

    To clarify:

    We only want to change the feature image of single portfolio items (e.g. https://mbguiding.ca/adventures/west-coast-trail/) from the current full-size image (2400px) to the entry-image size (895px). Why does the single portfolio item use the full-size version as default?

    Please send the complete code snippet for my child theme functions.php that will make the image smaller.

    Thanks, MB

    Vancouver Island Hiking Guide

    #1234279
    Paul R
    Moderator

    Hi,

    Here is the complete code.

    
    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 );
            }
          }
          
          if(is_singular('x-portfolio')) {
              $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
          }
    
          switch ( is_singular() ) {
            case true:
              printf( '<div class="entry-thumb">%s</div>', $thumb );
              break;
            case false:
              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 that helps.

    #1234926
    MB
    Participant

    [RESOLVED] That’s exactly what we needed, thanks Themeco! 😀

    #1235086
    Rahul
    Moderator

    Glad we were able to help you out!

    Let us know if we can help with anything else.

    Thanks for choosing the X-theme.

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