Resize image and add white space to exact size

0

I need to know how can I make images in wordpress instead of making hard-crop or resize simple in the image scale, Keep the image the size I want and if the image does not have the same scale as the intended result that the script / plugin does not wreck or crop the image.

Something like this:

    
asked by anonymous 25.03.2014 / 17:04

1 answer

1

With CSS you can:

CSS:

<!doctype html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <title>Exemplo pt.stackoverflow - Pergunta 10483</title>
    <style>
    .quadroImagem {
        display:inline-block; 
        margin: 0;
        padding: 0;
        width: 200px;
        height: 200px;
        text-align: center; 
        background-color: #FFF;
        border: 1px solid #999;        
        line-height: 196px;
    }
    .quadroImagem img {
        max-height: 200px;
        max-width: 200px;
        vertical-align:middle;
    }
    </style>
</head>
<body>

    <div class="quadroImagem">
        <img src="minha_imagem.jpg" />
    </div>

</body>
</html>

Remembering that when changing the default size (in the example, 200px) the line-height value should always be 4px smaller, ie:

For 400x400, line-height: 396px; For 100x100, line-height: 96px;

Line-height is used to allow vertical centering indicated in the image itself with vertical-align: middle;

Test and see. Use rectangular square images (with height greater than width and vice versa).

    
25.03.2014 / 18:47