- This topic has 15 replies, 2 voices, and was last updated 9 years, 3 months ago by Tom.
-
AuthorPosts
-
April 29, 2015 at 7:39 am #103736Carlos Paramio
Tom, I need to give a bigger size to the featured image in the first post of the masonry
I have added the PHP you gave me to create a class for the first post but I’m unable to identify the featured image. This is as far as I have been able to reach:
.blog .first .post-image,
.archive .first .post-image {
width: 500px;
height: 500px;
}With that I get a lot of empty space around the featured image but the image itself remains the size set in customizer
Thanks
April 29, 2015 at 8:00 am #103737Carlos ParamioI can’t believe I finally made it working by myself with this code, is it right?
.blog .first .attachment-generate-blog { width: Auto; height: 500px; }
April 29, 2015 at 8:10 am #103738Carlos ParamioUnfortunately the image height is resized as set in the Customizer (150px) and then, after that I guess, it is enlarged to 300px (the original size of the JPG file), resulting in a pixelated image 🙁
Any ideas?
Thank youApril 29, 2015 at 1:42 pm #103909TomLead DeveloperLead DeveloperMaybe try this:
.blog .first .post-image img, .archive .first .post-image img { width: 500px; height: 500px; }
April 30, 2015 at 9:25 am #104209Carlos ParamioSame result, the featured image in the first post gets pixelated.
Oddly, when I set in Customizer the height for the featured images, it doesn’t work until I type Auto in the width box.
I mean, Auto is set by default and I can see it in grey colour. Then, I set e.g. 200px in height box, but nothing changes neither in preview nor saving changes.I have to manually type Auto in the width box (it gets black colour) to make the featured images resized to the height I want.
I have tried deactivating the lightbox plugin with same result.
(I don’t know if this has something to do with the goal I want for the first featured image)
April 30, 2015 at 9:58 am #104220TomLead DeveloperLead DeveloperSetting the height to 500px in the CSS will cause the image to lose quality if it’s not the right aspect ratio. Removing the forced height will allow the image to adjust to it’s regular size (at 500px width) without losing quality.
You definitely shouldn’t have to type “Auto” into the size box – just leave it blank.
Let me know 🙂
May 30, 2015 at 4:57 am #111397Carlos Paramiohttp://www.unedtalavera.es/aulas/aula-de-illescas
Hi again Tom,
Let’s try to sort out this oneFacts:
– I’m always using 300px height files for featured image
– I set “Auto” as “Post Image Width” and 150px as “Post Image Height”
– Everything is fine
– Then I add the CSS you gave me in this topic to set 300px (the original dimension) for the height of the featured image
– It makes the image higher (and wider) but the image gets pixelated
– You can view the same image in the same dimensions, not pixelated, in the complete viewAs an aside note, I don’t seem to understand how “Post Image Width” and “Post Image Height” work in Customizer, because I’m obliged to write “Auto” in “Post Image Width” to make “Post Image Height” work
Thanks
May 30, 2015 at 9:20 am #111437TomLead DeveloperLead DeveloperHi Carlos,
If you set the height to 150px, WP will resize the image to that height.
If you then force the height to 300px, you’ll lose considerable quality. If you want the images to be 300px height, I suggest setting that height in the Customizer.
For the “Auto” values – don’t actually write Auto, just leave it blank.
Let me know if that makes sense or not 🙂
June 1, 2015 at 1:41 am #111724Carlos ParamioSo there isnt’ any possibility to avoid WP resizing images before forcing it to be higher?
Our wishes were that the first post in the site had a bigger featured image, that’s the reason why I don’t set 300px in customizer.
The “Auto” values keep behaving weird: I delete both boxes in Customizes (“Auto” appears in grey, you know), saved changes.
Then I come back in Customizer to make all the blog feaured images to have a 150px height, so I write 150 down in the “Post Image Height” box, but no changes are made in any post.
Then, if I write “Auto” in the “Post Image Width” box, all the images get the desired 150px height.Couldn’t it be a bug?
I must be doing something wrong or I’m not having something into account 🙁June 1, 2015 at 1:36 pm #111858TomLead DeveloperLead DeveloperAuto should appear in gray – just to let you know it will automatically calculate it.
I’ll have to look into that – the sizer might be wanting the width to be set to something. If you set it to an arbitrary number (9999), WordPress will ignore it and resize proportionally.
That being said, if you want the first post to have a different size, I would leave those fields untouched, then I would do this:
.blog .post:not(:first-child) .post-image img, .archive .post:not(:first-child) .post-image img { height: 150px; }
That’s some somewhat fancy CSS that will target all post images except for the first one, and will force the height to your value.
This way, the first post will stay at whatever you uploaded/have set.
Let me know if that does it or not 🙂
June 2, 2015 at 11:35 am #112092Carlos ParamioThanks Tom
So, I’ve deleted those fields in Customizer (of course they now appear as Auto in grey)
Then I’ve added that CSS but that made all the featured images to be 150px, including first one 🙁
By the way, all the images get the 150px height but they don’t have the width resized proportionally. Once again, I have added
width: Auto;
to the CSS and then they look fine.To simplify, I don’t care too much about the Auto issue, just need the first-post featured image to be bigger.
I have offered my boss the Meta Slider plugin to give first post more presence, but he hasn’t liked that solution…
Thanks
June 2, 2015 at 6:54 pm #112171TomLead DeveloperLead DeveloperHmm, weird that the CSS didn’t affect the first post.
Is the site viewable at all?
June 3, 2015 at 12:06 am #112185Carlos ParamioYes, please come in at
http://www.unedtalavera.es/aulas/aula-de-illescasJune 3, 2015 at 12:53 am #112188TomLead DeveloperLead DeveloperNice, you already have the firstpost class added to the post.
Try this now (as well as the other CSS):
.firstpost .post-image img { height: auto !important; }
June 3, 2015 at 8:45 am #112238Carlos ParamioBrilliant Tom, thank you very much! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.