How to Resize and Optimize Featured Images in the Twenty Fourteen Theme
Content
Many users of the Twenty Fourteen theme encounter challenges with how their images, particularly featured images, are displayed. A common issue is that images do not scale as expected after modifying the site's layout, or they appear at an incorrect size, leading to poor page performance and a negative impact on page speed tests. This guide explains why these problems occur and provides the most effective solutions.
Why This Happens
The Twenty Fourteen theme is designed with specific image dimensions and cropping behaviors to maintain its layout integrity. When you change your site's width or attempt to alter image aspect ratios, the theme's built-in styles and functions can sometimes conflict with your changes. Furthermore, the theme serves different image sizes in various contexts (like the featured content grid versus a single post), which can lead to full-size images being used as thumbnails, slowing down your site.
Common Solutions
1. Using a Child Theme and Custom CSS
The safest way to modify image behavior is by using a child theme. This prevents your changes from being overwritten during theme updates. A common request is to make images in posts scale to 100% of the container width. However, a broad CSS rule can affect images site-wide, including small thumbnails.
Targeted CSS for Single Post Images:
To specifically target only the main images on single post pages, you can use more specific CSS selectors in your child theme's style.css file or a custom CSS plugin.
.single-post .post-thumbnail img {
width: 100%;
height: auto;
}
This rule helps ensure that only the featured image on individual post pages expands to fill the content area, leaving other thumbnails untouched.
2. Modifying Image Sizes via Functions.php
Many users want to change the default cropped size of featured images, for example, to make them square (1:1 ratio) or to prevent cropping altogether. This must be done by redefining the theme's image sizes in your child theme's functions.php file.
Correct Code for Child Theme's functions.php:
It is crucial to use the after_setup_theme hook with a priority higher than the parent theme's (which is 10) to ensure your changes take effect.
function my_child_theme_setup() {
// Change default post thumbnail size to 700x366, cropped
set_post_thumbnail_size( 700, 366, true );
// Change full-width image size to 1200x628, cropped
add_image_size( 'twentyfourteen-full-width', 1200, 628, true );
}
add_action( 'after_setup_theme', 'my_child_theme_setup', 11 );
After adding this code, you must regenerate your thumbnails using a plugin like "Regenerate Thumbnails" for the changes to apply to existing images.
3. Solving the "Serve Scaled Images" Performance Issue
A frequent complaint is that the theme uses a large, full-width image file for small thumbnail displays (e.g., in the featured content grid), which hurts page load times. The solution is to ensure the correct image size is called in the template.
For example, to fix the grid on the homepage, you would need to override the theme's content-featured-post.php template file in your child theme. Find the line that outputs the image and change it to use a smaller registered size, like 'medium':
the_post_thumbnail( 'medium' );
Simply copying the template file to your child theme and making this edit should force the grid to use a smaller, more appropriate image file.
4. Removing the Featured Image Background
If a featured image is not large enough to fill its container, a grey background pattern may appear behind it. This can be removed with CSS in your child theme.
.post-thumbnail {
background: none;
}
Conclusion
Image sizing in the Twenty Fourteen theme is controlled by a combination of its PHP functions and CSS rules. The most reliable method for making changes is to use a child theme and carefully override these rules with more specific code. Always remember to clear your cache and regenerate thumbnails after making changes to see the correct results. For those concerned about the number of generated image sizes, the Twenty Fourteen theme creates several additional sizes, which is a common practice to ensure responsiveness across different devices.
Related Support Threads Support
-
Change image size to fit new site widthhttps://wordpress.org/support/topic/change-image-size-to-fit-new-site-width/
-
Ideal image size for retina displayinghttps://wordpress.org/support/topic/ideal-image-size-for-retina-displaying/
-
change featured image size / ratiohttps://wordpress.org/support/topic/change-featured-image-size-ratio/
-
Are there any or many additional image sizes in Twenty-Fourteenhttps://wordpress.org/support/topic/are-there-any-or-many-additional-image-sizes-in-twenty-fourteen/
-
Featured Image Post Backgroundhttps://wordpress.org/support/topic/featured-image-post-background/
-
content-featured-post.phphttps://wordpress.org/support/topic/content-featured-post-php/
-
Change featured image aspect ratio to 1:1https://wordpress.org/support/topic/change-featured-image-aspect-ratio-to-11/
-
Change thumbnail size in functions.phphttps://wordpress.org/support/topic/change-thumbnail-size-in-functionsphp/
-
Image control in postshttps://wordpress.org/support/topic/image-control-in-posts/
-
Twenty fourteen – Featured image (post) crop removehttps://wordpress.org/support/topic/twenty-fourteen-featured-image-post-crop-remove/
-
twentyfourteen_post_thumbnailhttps://wordpress.org/support/topic/twentyfourteen_post_thumbnail/
-
Changing Featured Image Sizehttps://wordpress.org/support/topic/changing-featured-image-size-2/
-
Scaling Features images in the Featured Posts at the First Pagehttps://wordpress.org/support/topic/scaling-features-images-in-the-featured-posts-at-the-first-page/
-
Twenty Fourteen theme loading full-sized image as thumbnail, then re-sizinghttps://wordpress.org/support/topic/twenty-fourteen-theme-loading-full-sized-image-as-thumbnail-then-re-sizing-2/
-
Resize featured image in post viewhttps://wordpress.org/support/topic/resize-featured-image-in-post-view/
-
Removing Feature Image from Post but keep on Gridhttps://wordpress.org/support/topic/removing-feature-image-from-post-but-keep-on-grid/
-
Featured images are cropped in grid and postshttps://wordpress.org/support/topic/featured-images-are-cropped-in-grid-and-posts/
-
og: imagehttps://wordpress.org/support/topic/og-image-1/
-
Different youtube embed size in ephemera widget and video post formathttps://wordpress.org/support/topic/different-youtube-embed-size-in-ephemera-widget-and-video-post-format/
-
Featured image linked to full size imagehttps://wordpress.org/support/topic/featured-image-linked-to-full-size-image/
-
Featured Image size problemhttps://wordpress.org/support/topic/featured-image-size-problem-1/
-
How to Specify Image Dimensions & Serve Scaled Imageshttps://wordpress.org/support/topic/how-to-specify-image-dimensions-serve-scaled-images/