How to resize wordpress image to fixed height and auto width

I have a WP slider with costum img sizes (fixed width and height) and i need that they would scale to fixed 330px height, and auto width. how to achieve this?

thank you in advance!

Related posts

Leave a Reply

4 comments

  1. As this was specific wordpress question and I found an answed, i will share it. When you add custom image size to functions.php, add 9999 to width and hardCrop to false.

    add_image_size('slider-thumb-alt', 9999, YOUR_FIXED_HEIGT, false);
    
  2. First when importing them via the media manager you can define the native size. Otherwise you will have to hard code them like @Dan Grossman mentioned. We need more info. Site link and slider name?

  3. It sounds like you already have a pretty decent idea of what you need. Use css to do this.

    For example:

    <img src="http://www.example.com/image.jpg" class="image_class"/>
    
    <style>
    .image_class{
    width: auto;
    height:330px;
    </style>
    

    You’ll want to target based on class (rather than all images with img{...}). I haven’t used WP Slider, but I’m assuming that it will add a custom class to images in the slider. If so just use your in-browser developer tools, or view source, to see what class is being added to these images, then create the css like the above.