<?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
- Custom Walker: how to get ID in function start_lvl
- How to include own css on wordpress tinymce editor?
- Change default status and replace the icon for an hamburger menu
- How to change email address used for registrations?
- Reasons why all thumbnail sizes aren’t working
- I want to submit multiple users if checkbox is checked
- need help with a user-specific custom page template
- Alphabetical Custom Menu
- Creating custom database table with crud operation
- How can I add interactive python console to my website? [closed]
- Show “Read more” link only when inserted manually
- create Custom field for tv series
- Data won’t save if metabox within conditional in admin. What am I missing?
- Restrict Viewing of post on both front and backend?
- Add array of post id’s to a category?
- How to create social Share Buttons Without Plugin
- Custom Avatars for WordPress Comments VIA Website URL?
- Structure of post types for TV Shows and episodes
- Background setting isn’t applied to entire sidebar height
- Function to query by custom field and category
- Custom user fields validation on registration
- Share user access between two wordpress sites
- Adding page Title in a custom coded page
- Reached end of document without finding – using mod_pagespeed
- How to import external media items into wordpress media library (without using storage)