Responsive image sizes – custom CSS or plugin?
-
I would like to make image sizes responsive in my blog posts (not in the main pages of my site) in particular for large portrait-orientation images.
I’m using WordPress 4.9.5 and Pique child theme (Pique version 1.4.2)
The ideal behaviour I would like:
– for screen sizes smaller than 500px, display the image in question at 100% width of the column.
– for screen sizes larger than 501px, display the image at 70% of the width (or max-width 600px – the max size of the main column in Pique theme is 857px)
– Maybe (but I imagine I need a plugin for this) make the images clicable to see them full-size in a lightbox, if they have been reduced.I tried adding some css to my child theme :
@media screen and (max-width: 500px) { .imgv { width : 100% ; } } @media screen and (min-width: 501px) { .imgv { max-width : 600px ; } }
also tried :
@media screen and (min-width: 501px) { .imgv { max-width : 70% ; } }
Then I added the CSS class “imgv” to the image I wanted to modify. I tried doing this via the “CSS class” field in the wysiwyg image editing dialogue or manually directly in the html code of the image, replacing the image size class and also deleting the hardcoded width and height. In both cases the new css was not applied and the images are still displayed at full-size even if I maximize the window.
Here is an example of the default html code :
[caption id="attachment_3729" align="aligncenter" width="768"]<img class="wp-image-3729 size-medium_large" src="https://lesbeauxebooks.com/wp-content/uploads/2018/05/certificat-768x1024.png" alt="Reproduction d'un tableau au format fluide" width="768" height="1024" /> Ceci n'est pas un tableau[/caption]
The images in question are 768x1024px (portrait orientation) when set to “medium-large” size, that means a lot of scrolling, but medium size is 225x300px, that’s too small for what I want.
Can I do this with custom CSS ? If yes, how can I do it so that it is taken into account ? If not, can you recommend a good, simple plugin for it ? I searched for responsive image plugins but they seem to all be for responsive galleries / sliders, not single images.
Unfortunately I can’t link you directly to the page because the article isn’t published yet and I’d rather not publish it until I have sorted this. :\ But if more information is needed I’ll try to find a solution. The site in question is here: https://lesbeauxebooks.com
Thanks in advance for any assistance you can give.
- The topic ‘Responsive image sizes – custom CSS or plugin?’ is closed to new replies.