- This topic has 12 replies, 3 voices, and was last updated 6 years, 6 months ago by Tom.
-
AuthorPosts
-
April 7, 2017 at 2:01 pm #303121Elio Martinez
Hi,
I want that all the featured images of my posts stay with a width of 200px in Masonry option, but I need that the most recent post selected as “Sticky” has a bigger width. It is possible that with some css or code?
Thanks.
April 7, 2017 at 2:07 pm #303122LeoStaffCustomer SupportHi Elio,
Are you able to provide a link to your site? I’ll see if I can come up with something.
Let me know.
April 7, 2017 at 2:34 pm #303127Elio MartinezMy site is nbamaniacs.com
I want only one column with a sidebar, not two or three columns plus a sidebar.
April 7, 2017 at 2:50 pm #303139LeoStaffCustomer SupportIf you want only one column then try disabling both Columns and Masonry in Customizer > Blog.
Let me know if this is what you wanted.
p.s. Dubs all the way π
April 7, 2017 at 3:57 pm #303175Elio MartinezLeo,
The thing is that I want all the featured images in the home with a 200px width BUT the images in the sticky post much bigger.
April 7, 2017 at 5:01 pm #303196LeoStaffCustomer SupportTry this CSS for sticky post featured image size:
.sticky .post-image { max-width: 500px; }
Let me know.
April 7, 2017 at 7:23 pm #303242TomLead DeveloperLead DeveloperMight be best to set the image dimensions for the large image, then use CSS to make them smaller on the smaller posts.
Otherwise you can use a function like this: https://docs.generatepress.com/article/adjusting-the-featured-images/#changing-the-featured-image-sizes-using-a-filter
Using a conditional like this: https://codex.wordpress.org/Function_Reference/is_sticky
April 8, 2017 at 11:01 am #303436Elio MartinezWhich is best? css for not sticky images (don’t know the exact css code) or the function that Tom wrote?
April 8, 2017 at 4:22 pm #303515LeoStaffCustomer SupportI would say using the function would be the best way. Try this code below and adjust the width and height to what you want on sticky post:
add_filter( 'generate_blog_image_attributes','tu_variable_image_sizes' ); function tu_variable_image_sizes( $atts ) { // Set up our conditional if ( is_sticky() ) : $atts[ 'width' ] = 300; $atts[ 'height' ] = 300; $atts[ 'crop' ] = true; endif; // Return our options return $atts; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
September 14, 2017 at 2:36 pm #385567Elio MartinezHi,
I have solved this but now I have a problem: if I select three posts as sticky, the three of them have a big photo. It is possible to make a function so only the most recent sticky has the big image and the older stickys the same photo size as the non-sticky?
September 14, 2017 at 11:08 pm #385733TomLead DeveloperLead DeveloperYou could try this instead:
add_filter( 'generate_blog_image_attributes','tu_variable_image_sizes' ); function tu_variable_image_sizes( $atts ) { global $wp_query; // Set up our conditional if ( 0 == $wp_query->current_post ) { $atts[ 'width' ] = 300; $atts[ 'height' ] = 300; $atts[ 'crop' ] = true; } // Return our options return $atts; }
September 14, 2017 at 11:58 pm #385754Elio MartinezSolved! π
September 15, 2017 at 9:12 am #386029TomLead DeveloperLead DeveloperAwesome π
-
AuthorPosts
- You must be logged in to reply to this topic.