Tagged: x
-
AuthorPosts
-
November 5, 2016 at 2:15 pm #1245232
XcitingWebParticipantHi!
I want the featured images on a website of mine to be pulled from the thumbnail-sizes and not the full-sizes, because they are really small. Pulling from the thumbnail-sizes would speed up the websites because the loaded images are smaller.What do I have to add to the functions.php of the child of the X-Theme to make that happen?
Thank you very much for your help!
November 6, 2016 at 1:26 am #1245596
Rue NelModeratorHello There,
Thanks for writing in! By default the featured image is displayed using the pre set image dimension in X. Sometimes it is displayed as in full size. To display the smaller dimension, please insert this following code in your child theme’s functions.php file.
// Custom featured image displaying the smaller size image dimension in blog index // ============================================================================= 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_home() || is_archive() ){ $thumb = get_the_post_thumbnail( NULL, 'thumbnail', NULL ); } switch ( is_singular() ) { case true: $get_description = get_post(get_post_thumbnail_id())->post_excerpt; //var_dump($get_description); if(!empty($get_description)){ //If description is not empty show the div echo '<div class="img-caption">' . $get_description . '</div>'; } 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; } } } // =============================================================================And if the thumbnail size is too little, you can change it to medium or large. Just find and replace it in this lines:
if ( is_home() || is_archive() ){ $thumb = get_the_post_thumbnail( NULL, 'thumbnail', NULL ); }Hope this helps.
November 7, 2016 at 1:27 am #1246643
XcitingWebParticipantHi!
Thank you very much. This worked perfectly! I attached my functions.php for future use. Solved!November 7, 2016 at 2:08 am #1246676
Rue NelModeratorYou’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread. -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1245232 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
