vendredi 27 février 2015

How to crop image height (and center it) without changing html and ratio?

In wordpress, I want to show a height reduced image but keeping width and ratio. The image is 400px large and 300px height. I want it 400px large but only 200px height, and centered.


This solution may help me but is uses div ? Crop and center image without using background-image But I can't add any div around image because wordpress doesnt create any. May be could I create a div using PHP ou JS ?


Here is the html created by Wordpres :



<p>
<a href="http://ift.tt/1AzyFIf">
<img width="400" height="300" src="http://ift.tt/1AzyFIf">
</a>
</p>


and a JSFiddle to try : http://ift.tt/1AfzGAo


If anyone can help me, thanks a lot !!!


Aucun commentaire:

Enregistrer un commentaire