Tag Info

Hot answers tagged

11

Add this code to your theme's functions.php file, and it will limit minimum image dimentions add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter'); function tc_handle_upload_prefilter($file) { $img=getimagesize($file['tmp_name']); $minimum = array('width' => '640', 'height' => '480'); $width= $img[0]; $height ...


10

A very special filter The jpeg_quality filter is a really special one: It gets used in three different cases and you've to use the second argument to determine, if you want to use the filter or not. Don't let it do everything The main problem for such a special filter is, that it may fire for later actions, if you ain't remove it - allow it to run after ...


9

You can over write the default like this: add_image_size( 'medium', 200, 200, true );


9

For post thumbnails you can either crop and image to the thumbnail size or scale the image. To enable crop you can call the thumbnail 1 of 2 ways. Name a size in the functions.php file like so: <?php add_image_size( 'my-post-thumbnail', 494, 168, true ); ?> and then call it in the theme file <?php the_post_thumbnail('my-post-thumbnail'); ...


8

I created two plugins that together should solve my needs. They are currently in an early alpha stage, and all comments are welcome. The base plugin is an On-Demand Resizer. This plugins monitors requests for non-existing files in the uploads dir, and creates images of the requested size if needed. For example, image-200x100.jpg will create and return ...


8

When an image is uploaded in Wordpress, it is saved in its original size, and also in some resized copies in different sizes, in this way became easy use different size of the same image for different purpose. By default, WordPress, create 3 copies in 3 different size: 'thumb' 'medium' 'large' The size in pixel for these 3 sizes can be setted in ...


8

Philipp, anything is possible if you set your mind to it. You can solve your issue by extending the WordPress image editor class. Note I'm using WordPress 3.7 - I haven't checked any of the below code in earlier versions and in the latest 3.8 release. Image Editor basics WordPress has two built in classes that handle image manipulation: ...


6

There are a few steps to this, as I found out today. First, you add a custom image size (you can put this somewhere the functions.php file in your theme): add_theme_support( 'post-thumbnails' ); add_image_size( 'my-size', 550, 550 ); // not sure what you want your height to // be, but this'll shrink it to 550px ...


6

Hi @jaredwilli: Dude! Valiant effort, and nice work. All-in-all it could be a great addition to WordPress. You were so close, but you had somewhere between 5 and 10 little failed assumptions or code that looks like you started it but didn't get back to it because it wasn't working. I reworked your function only as much as I needed to correct it. The ...


5

The issue is that WordPress always maintains the aspect ratio on your photos. For a lot of uses, this makes sense. However, if you're trying to line up a bunch of images — some in portrait, others in landscape — it can be a real pain. If you want to fix this, you can register a new image size in your functions.php file in your theme. For example, I just ...


5

No, wordpress can not resize BMP files. Beware that it does not make sense to use BMP files in a website because a broad number of webbrowsers is not able to display them. Filetypes that are supported by Wordpress and which are widely supported by internet browsers are: GIF, JPG and PNG. Those formats are optimized for internet use as they compress image ...


5

Found it here. The answer is: global $_wp_additional_image_sizes; print '<pre>'; print_r( $_wp_additional_image_sizes ); print '</pre>';


5

I think the only solution you have at the moment is to disable all intermediate image sizes: add_filter( 'intermediate_image_sizes', '__return_empty_array', 99 ); And then manually generate them, depending on the post type, by hooking into 'wp_generate_attachment_metadata', where you do have access to the attachment id (and therefore to it's parent post): ...


5

If you want WordPress to hard-crop the images to those absolute image dimensions, you can set the $crop argument of add_image_size to true, by default it is false: add_image_size( 'thumbnail-small', 179, 147, true );


4

I prefer not to reformat a colleague's code. So, this is almost the same answer as @MaorBarazany's, but checking the mime type, changing the file['error'] declaration and changing the function namespace to this wpse Question ID. Also, the check only occurs for users that are not administrators. add_action( 'admin_init', ...


4

The 'jpeg_quality' filter hook functions accept two arguments: $jpeg_quality and $function which is the function from within the filter hook is fired and can be either image_resize or wp_crop_image. So there is no way to selectively set the quality of .jpeg images according to image size from this filter hook function. However, you still can hook to a later ...


4

add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes'); function filter_image_sizes( $sizes) { unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; }


4

Misspelling of thumbnail (thumnail) in the if statement. Also get_the_post_thumbnail does echo the thumbnail, but just returns the html. You need to echo it. Also, for checking if a post has a thumbnail, you can use has_post_thumbnail. if ( has_post_thumbnail($r->ID)) { echo get_the_post_thumbnail($r->ID, array(50,50)); }else{ echo ...


4

There is a way, I recommend you combine the imagefx plugin with a custom function , http://wordpress.org/extend/plugins/imagefx/ You can read about it here: http://ottopress.com/tag/gd/ , and use a function like one found here: http://stackoverflow.com/questions/1201798/use-php-to-convert-png-to-jpg-with-compression It would look something like (not ...


4

WordPress automatically resizes uploads into different formats based on the settings on the Settings » Media page: You can set up all of your different default sizes here. Though keep in mind that plug-ins and themes can define their own custom image sizes ... so I can't guarantee perfect operability in all cases.


4

I am assuming that WP takes the additional parameters at the end of the file name to automatically resize the image... Wordpress adds those suffixes when it creates the images, which is typically done on image upload. Those images should be on the server. By default (and if I am not mistaken), WordPress does not do any dynamic image resizing on page ...


4

You can call add_image_size in your functions.php: add_image_size( 'medium', 240, 160, true ); Reference here: http://codex.wordpress.org/Function_Reference/add_image_size


4

I asked a similar but broader question, and I still need to research and write a complete answer. In the meantime here are some pointers that might help you: I wrote a set of plugins that resizes all images to the size used in the editor. It works by converting <img src="image.jpg" width="200" height="400"/> to <img src="image-200x400.jpg" ...


3

Being the author of the plugin in question, there actually is a limit. (It's 360x360.) Else +1 to Davy8's answer. I could add a define in a future version...


3

You can try looking at this plugin WordPress ImageMagick Engine Replaces wordpress image resizing from GD to ImageMagick. You need a compatible host to use it though


3

Wordpress creates new images when add_image_size() is used. When it does, it appends the file URL with the size. If you have access to the uploads folder on both servers, you may need to manually transfer the files from your old one to your new.


3

I have searched the plugin directory for "resize" or "crop" (the latter for another question), and noted my findings in a public Google spreadsheet. The plugin search is very confusing in its result numbers (the last page of the "resize" search shows "Showing 145-150 of 273 plugins"), so I may have missed a few. Semi-related notes: everybody seems to think ...


3

You can use this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/.


3

You need the bulk image resize utility: http://wordpress.org/extend/plugins/bulk-image-resize-utility/ I have used that numerous times and it does a fantastic job!



Only top voted, non community-wiki answers of a minimum length are eligible