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!

Answers


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);

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?


<img src="http://www.example.com/image.jpg" height="330" />

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.


Need Your Help

Command to rebuild applicationHost.config in IIS 7

iis-7 windows-server-2008 http-status-code-401 applicationhost

Is there a way to rebuild the applicationHost.config file in IIS 7 with a Windows command? Or if you can help me fix the issue by modifying this file, that's fine too. When comparing this file to...

Accessing objects in NSMutableDictionary by index

objective-c iphone cocoa-touch xcode

To display key/values from an NSMutableDictionary sequentially (in a tableview), I need to access them by index. If access by index could give the key at that index, I could than get the value. Is