add the size to your images sizes using add_image_size()
to your theme’s functions.php file. eg:
if ( function_exists( 'add_theme_support' ) ) {
add_image_size( 'index-thumb', 220, 180 ); // 220 pixels wide by 180 pixels tall
}
then set the image as featured image from the media uploader of the posts :
then open your index.php and replace the image tag that is calling the timthumb.php
file for resizing with:
if(has_post_thumbnail()) {
the_post_thumbnail('index-thumb');
} else {
//show default image if none is set
echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" />';
}
Related Posts:
- Timthumb.php image gallery not working on Multisite WordPress
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- How to add a class to the attachment images
- How do I hook into WordPress to save an uploaded photo as an alternate size to an existing photo?
- How to check if image is already stored in a site’s post database? (network)
- Adding a custom image upload size and making it selected by default?
- Hide custom image sizes from media library
- Change the filename format of saved featured images
- How to draw media details for Isotope gallery using Photoswipe
- How to register images uploaded via FTP in media library?
- Create Image Uploader for Widget
- Using file_exists to check file in Uploads
- Permanently remove first image from posts
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- Admin Media grid view images won’t load
- WordPress remove EXIF Data from specific Thumb
- Debugging upload problem: What part of WP does actual image-resizing?
- How to resize image on client-side before upload?
- Adding Featured Image to Post programatically
- Add custom image sizes to media uploader
- Conditional Statement – check if post has an attachment image
- How to upload imagick resource to media in wordpress
- Use Filename for Alt and Title Tags
- Change Width of Featured Image Thumbnail on Add/Edit Post Page
- Get a Page’s attachments in Gallery order
- Use Timber/Twig to pull an image by image ID [closed]
- Adding graphics to 404.php page
- How do I get images (with a thumbnail preview) to show in search results?
- How to get custom image size for image uploaded in Customizer
- Add custom HTML to posts page
- Scrape external webpage for first image and add it to new post
- How to make own crop image function for WordPress plugin
- “imagejpeg” function is not working in wordpress
- Display image from an external rss feed on wordpress without plugins
- WordPress automatically adds links to uploaded images
- WordPress function when file is uploaded, deleted or edited
- Download images from media library to computer in BULK?
- Three Questions with Twenty Eleven theme
- How to loop through all the attached images in a post, and get their url one by one
- Which function crops images in wordpress?
- Division by zero error in image.php
- Resize image to specific dimension (X to Y ratio)
- How can I automatically resize up images to fit into all of my registered image sizes
- Clickable image link sends people to wrong URL
- Only show image from custom field when present
- Upload non-featured image to image field
- Where are the src and srcset sizes coming from?
- HTML showing after PHP code in tag
- Only show first image in foreach loop
- trying to get wp_get_attachment_url to output clickable link
- Change default gallery images – Currently they are displaying full size imagese
- I’m unable to call img path using single quotes in an array?
- Creating black and white copy of an image [closed]
- Get the id of all images in a post
- Shortcode function doesnt work without caption
- Get featured image with custom size outside WordPress
- Images Uploaded saving onto older/previous year folders
- Display an image based on field value
- Else/If Statement to Display Photo Descriptions
- Add valid XHTML closing img tags to WordPress galleries
- How to set a featured image (thumbnail) with PHP?
- Convert canvas to image and upload image to server
- Controlling image output size ACF repeater [closed]
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- WordPress İmages Upload & Delete Error
- Generate responsive post thumbnails of same size
- How to Make Thumbnail of Post Stay Animated
- Attaching images to posts manually (i.e. with custom code, without the use of an API)
- Adding a ‘style=’ bit to image_send_to_editor output
- Convert all uploaded PNG files to PNG-8 format
- foreach repeat html structure after every nth for attachment [closed]
- CSS images don’t show up with bloginfo
- How to internationalize header image?
- Some problems in custom widget
- Displaying images outside the content
- Checking page before applying image restrictions while uploading
- Generate images with html2canvas and the woocommerce api
- Change extension to .jpg when webp is not supported
- WordPress api post image raw data without being blank in media library
- Prepend to all image URLs with PHP, only for mobile devices
- Retrieve alt text by referencing the img src
- Show next image in array if page is revisited by same logged user
- WordPress loading all local images from specific directory?
- Change the URL of an image from wp_get_attachment_image_src for Product Posts based on Category
- Update Images after edit via php
- not outputting medium size image URL
- Configure WordPress to Use Responsive Image Rendering
- How to use data URL in WordPress?
- Replace background image with post thumbnail in shortcode
- Resize post thumbnail
- Where Do Image Dimensions Get Added To A Filename?
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- How do I stop an Image Address from loading in the Browser?
- How to get the url of the entry in which an image belongs
- How to add a PHP scripts into WordPress
- Featured images duplicating and replacing next image
- Get list of posts from attachment
- I can’t load my images from a js file using wp_localize_script