Tagged: x
-
AuthorPosts
-
September 21, 2016 at 11:11 pm #1185924
GATHHParticipantHi there,
When I upload a new image to a post, the following sizes are generated:
100×67, 150×150, 300×200, 500×334, 500×500, 500×587, 768×512, 862×482, 862×575, 880×500Currently, X uses the following image size for my featured posts:
862×575How can I force X to use this size instead:
880×500Or better yet, where can I change the size of the generated images? I.e. Instead of having x generate this size 862×575, how can we change it to generate this size: 900×600
Thanks.
September 22, 2016 at 12:41 am #1186016
Rue NelModeratorHello There,
Thanks for writing in! What you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
After the child theme is set up, please add the following code in your child theme’s functions.php file
// Custom featured image displaying the large size image dimension on archive pages // ============================================================================= 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() ) { $thumb = get_the_post_thumbnail( NULL, 'large', 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; } } } // =============================================================================You can change to medium, large or full image size in this line:
$thumb = get_the_post_thumbnail( NULL, 'full', NULL );Hope this helps. Please let us know how it goes.
September 22, 2016 at 12:47 am #1186021
Paul RModeratorHi,
Please do the following.
1. Add your image size by adding the code below in your child theme functions.php file
add_image_size( 'gathh-size', 220, 180 );2. Install, activate and Run Force regenerate thumbnails plugin
3. Change featured image function to pull your new image size by adding this in 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 ); } } $post_thumb = get_the_post_thumbnail( NULL, 'gathh-size', NULL ); switch ( is_singular() ) { case true: printf( '<div class="entry-thumb">%s</div>',$post_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.
September 22, 2016 at 4:45 am #1186222
GATHHParticipantHi Rue Nel,
Thanks for your reply. This worked well. However, now it shows string(0) “” above the photo. See screenshot attached.
What do I need to change in the code to remove this?
Thanks.September 22, 2016 at 7:34 am #1186346
Paul RModeratorHi,
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 credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
September 22, 2016 at 9:45 pm #1187402
GATHHParticipantThis reply has been marked as private.September 23, 2016 at 12:05 am #1187500
Rue NelModeratorHello There,
Thank you for the very detailed information. I have logged in and have already fixed the issue. It was just a var_dump() function in the given code. Nothing to worry about. It is already gone.
Is this what you are looking for? Please confirm if this has resolved the issue.
Thank you very much.
September 23, 2016 at 1:54 am #1187589
GATHHParticipantHi Rue,
Thanks a lot. Really appreciate your help. This has resolved the issue.
You guys rock!September 23, 2016 at 2:05 am #1187603
Paul RModeratorYou’re welcome! 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1185924 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
