Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Set height only - featured images

Featured Replies

Good afternoon Folks!

 

I am trying to add featured image to a post page. As the images are always going to be different sizes and I don't want them to be cropped, I thought perhaps I could set a set-height. I figured I could then somehow set it so that the width was auto and would just adjust accordingly to fit the image size and keep the proportion.

 

How do I do this?

 

I have tried this so far:-

<?php echo get_the_post_thumbnail( $post_id, array('auto',300), $attr ); ?> 

But this did not work.

 

Any help would be appreciated :-)

You could try and add a new featured image size to functions.php

add_image_size( 'page-feature-image', 500, 175, true );

 

By setting it to true it will scale the image to the exact size. If you upload an image larger than this it will scale it down as much as possible then trim off the edges.

 

and then in your theme use this where you would like to display this image

 

<?php the_post_thumbnail( 'page-feature-image' ); ?>

 

Just remember that if you add a new feature image size it will only be applied to new image uploads so you will have to reupload the image to test and if it works you can use this plugin to regenerate all the images. http://wordpress.org/plugins/regenerate-thumbnails/

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.