I have some HTML created by wordpress generated data that basically shows images within a div.
I want the following if possible;
If div has less than 4 images - only show the first image in the div! Here is the example HTML generated;
<div class="display-block">
<img src="image">
<img src="image">
<img src="image">
<img src="image">
</div>
<div class="display-block">
<img src="image">
<img src="image">
<img src="image">
</div>
So based on the above, the first display-block div will show all its children images, but the second one which only has 3 children images, will only show the first image.
This is basically so i can fill a thumbnail equally visually.
Here is a screenshot also so you can see what I mean;
So, the first block 'productivity' only has two images and doesn't fill the its container nicely. This is what i want to target like so
This div has less than 4 images, so hide all but the first one and make it fill it's container which I can do by changing image max width. The second block 'code snippets' only has 1 image and fill's it's container nicely because I was able to target this with the only-child selector.
And then the 3rd block 'website design inspiration' has 4 or more images, so it pulls the first 4 and fills its' container nicely.