- This topic has 12 replies, 3 voices, and was last updated 4 years, 8 months ago by
Tom.
-
AuthorPosts
-
April 7, 2017 at 2:01 pm #303121
Elio 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.
GeneratePress 1.3.46GP Premium 1.2.96April 7, 2017 at 2:07 pm #303122Leo
StaffCustomer 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 7, 2017 at 2:34 pm #303127Elio Martinez
My 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 #303139Leo
StaffCustomer 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 π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 7, 2017 at 3:57 pm #303175Elio Martinez
Leo,
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 #303196Leo
StaffCustomer SupportTry this CSS for sticky post featured image size:
.sticky .post-image { max-width: 500px; }
Let me know.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 7, 2017 at 7:23 pm #303242Tom
Lead 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
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 8, 2017 at 11:01 am #303436Elio Martinez
Which 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 #303515Leo
StaffCustomer 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/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 14, 2017 at 2:36 pm #385567Elio Martinez
Hi,
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 #385733Tom
Lead 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; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 14, 2017 at 11:58 pm #385754Elio Martinez
Solved! π
September 15, 2017 at 9:12 am #386029Tom
Lead DeveloperLead DeveloperAwesome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.