Last active
December 15, 2015 22:00
-
-
Save florieger/5330176 to your computer and use it in GitHub Desktop.
Wordpress custom image sizes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // This File will be read by the wordpress engine, handle with care | |
// ========== AppCron Image Handling ========== | |
// Remove default image sizes | |
function ac_remove_image_sizes( $sizes) { | |
unset( $sizes['thumbnail']); | |
unset( $sizes['medium']); | |
unset( $sizes['large']); | |
return $sizes; | |
} | |
add_filter('intermediate_image_sizes_advanced', 'ac_remove_image_sizes'); | |
// Enable featured image support for posts | |
add_theme_support('post-thumbnails'); | |
// Add custom image sizes | |
set_post_thumbnail_size( 450, 250, true ); // 2y Featured image [cropped] | |
add_image_size('ac-img-s1', 130, 130, true); // 1x thumbnail [cropped] | |
add_image_size('ac-img-s2', 290, 217, false); // 2x preview [exact height for 4:3] | |
add_image_size('ac-img-s4', 610, 500, false); // 4x detail pictrue [variable height] | |
add_image_size('ac-img-s6', 930, 930, false); // 6x full page width [max height] | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important:
The new images sizes will not been shown in the WordPress backend UI.
You can only use them in the code of your template.