<?php
// First, enable thumbnails if they are not enabled yet
add_theme_support( 'post-thumbnails' );
/*
* Add image dimensions
*
* name
* width
* height
* crop or resize (true or false)
*
* 99999 means very big number
*/
add_image_size( 'featured-portrait' , 200 , 99999, false );
add_image_size( 'featured-landscape' , 99999, 200 , false );
// Next, choose names for these dimension sets
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'featured-portrait' => __('Portrait, 200px wide'),
'featured-landscape' => __('Landscape, 200px high'),
) );
}
You can vary width, height and crop to fit your needs.
Related Posts:
- Image Editor does not affect custom sizes!
- Using custom image resizing script in a page
- Redirect to another page using contact form 7? [closed]
- Featured Image If Else Condition
- WordPress 5: including larger thumbnail image sizes in srcset than I have set
- Upload image without resizing but insert in post with resizing
- How to get the Date Format and Time Format settings for use in my template?
- Why doesn’t WP_Image_Editor save images using the Filesystem API?
- How to create thumbnails with a fixed width, so all of them will have the same width?
- Is there a plugin to make attaching images easier?
- Managing Images for a WordPress Blog: Picasa or Flickr?
- Custom editor field displaying HTML in Visual editor
- Automatically wrap post image in div
- wordpress custom walker for thumbnails with custom menu
- Custom image size not selectable in uploader
- Retrieving and Storing Images Linked from Other Domains on Local Server?
- Customizer image control default value showing in customizer but not on frontend
- Setup A Default Featured Image
- On Install, which code sets the ‘home’ option?
- Importing media medium setting image gallery / image attachments
- Extract & Display the REAL first image attached to a post – extend the_post_thumbnail()
- How to use get_option() without any filter?
- Add filename to attachment page url
- Custom widget select options needs to stay selected after save
- How To Add buttons to the toolbar which appears in TinyMce when you click over images
- Hide upload image fields for the different media upload popups
- How to display post title & excerpt when mouse hovers on an image?
- Include user defined styles without including wp-load
- Remove image classes from post thumbnail output
- Automatically add image caption with values from a post parent field?
- Is there a way to dynamically get to your uploads folder?
- Warning: Creating default object… when altering Customize panels
- How do I Add images uploaded in the post to a default custom field
- Using Fullscreenr with a wordpress blog – weird bug
- WordPress slugs and 404 handling takes preference over folders in site root?
- What changes we need to make to a theme so it can be installed as a MU Theme?
- Get Image from Media Library with the Title
- Get Custom Logo Alt Text
- Background image not appearing
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Post thumbnails not working in my new install of WP 3.1 with Twenty Ten theme
- the_post_thumbnail() returns nothing even though has_post_thumbnail() returns true
- Best way to allow overwriting images shipped with the plugin?
- NextGEN Gallery – open all images on page in fancybox [closed]
- If custom image header does not exist display text header
- Is there a possiblity to replace profile image gravatar with custom user images
- Custom theme – how to link the image without posting it
- Trying to set specific image dimensions and crop with ACF
- Customizing the gallery of the post correctly
- Personalized Gallery what are my options?
- How to hide featured images of all posts falling under the same category in wordpress?
- How do I make mysite.com/comingsoon WordPress to become my main website’s WordPress?
- adding fade on mouseover to images
- Lightbox not showing image caption
- POST 429 Error when trying to place more than 20 images into post at once
- duplicate featured image functionality in custom meta box
- Creating custom setting in add media popup
- Bio comes up when the visitor clicks on a picture
- Adding images to anchors in the list created and fetched with wp_nav_menu
- Change default “Apply Changes To” radio option when editing images
- WP_Customize_Image_Control and selecting from library?
- Edit a custom admin page
- how to register / add multiple options into one field in wordpress?
- Custom options – register, defaults and delete empty fields (Settings API)
- How to delete orphan userdata from array in wp-options
- How to strip thumb from widget
- retrieve theme custom settings
- featured images – custom links
- Get a different size of Image thumbnail while working with custom metabox
- Custom image sizes ignored in WP 3.5
- WordPress uploads directory. Featured Images storage
- Edit image alignment in WordPress twentysixteen child theme on attachment page [closed]
- Set custom banner image size with wp_customize
- How to search for replacement titles and contents, excluding image URLs
- Custom Search on media files PDF images pages posts
- Images in an RSS feed
- How to disable the PDF preview in the file block by default
- Sticky menu for WP custom menubars
- images not showing despite using add_theme_support(‘post-thumbnails’);
- What can i do add title to ‘large’ image?
- Retrieve Image Attachments Getting Post Thumbnail Image First
- Change the style of h1, h2, only in post entry
- how to add custom logo to my template
- Woocommerce – Print Product’s Custom Field In Email
- Height and width attribute not setting by the_post_thumbnail
- Don’t change Custom Post Type slug to unique value
- Need custom picture field for pages
- How to display original unmodified thumbnail
- Search URL parameters query [duplicate]
- Is it possible to add posts and images (auto resize) for custom post types with a script?
- Semi complicated custom taxonomy question
- Custom Columns WordPress Admin
- Extending core class in plugin
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- How to hide image-url if no attachment?
- Archive subtitles for different types of archives
- Resizing thumbnails retrospectively
- Point homepage to custom php page
- Trying to show link “Use as featured image” from Attachment window from t31os script
- Simplify the admin end