Tag Info

Hot answers tagged

13

The only time setting the quality really matters is right before the image is saved or streamed (for the editor). Both of these have the "image_editor_save_pre" filter there, passing it the instance of the image editor. So you can use that to modify the image in any way you like, including setting the quality. So, something like this should do the job ...


9

Take a look at Otto's Dynamic Image Resizer plugin This plugin changes the way WordPress creates images to make it generate the images only when they are actually used somewhere, on the fly. Images created thusly will be saved in the normal upload directories, for later fast sending by the webserver. The result is that space is saved (since ...


7

No, it won't create a new image that is exactly the same size.. nor should it. All the thumbnail, medium, and large images are resized images, by definition. Since the original image is already 600x600, there's no point in creating another file at the same size, but with a lower quality (remember that JPEG compression is lossy). However, if you specify in ...


6

To built on Max Yudin's answer you should use the intermediate_image_sizes_advanced filter, and not image_size_names_choose. function add_image_insert_override($sizes){ unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); } add_filter('intermediate_image_sizes_advanced', 'add_image_insert_override' ); Another easier ...


5

You can use the native Wordpress image_resize function to scale up images. Wordpress provides a hook called "image_resize_dimensions" which you can use to overwrite the default cropping settings. Here is a modified function which will support scaling up: function image_crop_dimensions($default, $orig_w, $orig_h, $new_w, $new_h, $crop){ if ( !$crop ) ...


5

Basically you just retrieve the info via getimagesize(), a basic PHP function, a then handle your errors with notes. The plugin A basic plugin as a starting point: <?php /** Plugin Name: (#67107) »kaiser« Restrict file upload via image dimensions */ function wpse67107_restrict_upload( $file ) { $file_data = getimagesize( $file ); // Handle ...


5

I believe your issue is that the value set for the global $content_width variable (which is 640px in Boilerplate and 584px in Twenty Eleven) is less than the width you're specifying via Settings -> Media. WordPress is overriding your user setting with the Theme-specific value. This actually makes sense, since a Theme knows its maximum content width, and ...


5

i guess you are looking for this add_attachment and delete_attachment example: add_action('add_attachment', 'attachment_manipulation'); function attachment_manipulation($id) { if(wp_attachment_is_image($id)){ //do your own tasks } }


5

Note upfront: Below answer isn't finished and is not tested, but I ain´t got enough time left, so I'll leave this here as draft. What probably needs a second pair of eyes is the quality method and the interpretation of version_compare(). First we need an entry point. After reading through the make post again, I thought best would be to jump in before the ...


4

WordPress by default is designed to generate 3 types of cropping of any uploaded images (Media): Thumbnail (Typically 150px x 150px) Medium (Typically 300px x 300px) Large (Typically 1024px x 1024px) It's to ensure site speed with different sizes where necessary. So, with uploading the Original image there would be at least 4 files- The Original File ...


4

Yes, WordPress resizes & crops all images depending on what your theme defined as @Gerard already explained in his answer. So the last boolean argument for add_image_size() is to crop or not. Note that this doesn't define the crop position. To alter that behavior look at this answer for example. What happens inside core? As you've already seen in the ...


4

I'd try saving it as a PNG 24 first. If that doesn't work have a look at these: http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/ http://stackoverflow.com/questions/6382448/png-transparency-resize-with-simpleimage-php-class


4

Figured it out after a lot of trial and error and a lot of var_dumps. $image = wp_get_image_editor($file); if ( ! is_wp_error( $image ) ) { $image->resize( $width, $height, true ); $final_image = $image->save( $file ); } Then i can use the $final_image array to get what i need. It actually saved me a step from what i was doing and seems ...


4

You can also filter intermediate_image_sizes with an empty array. add_filter( 'intermediate_image_sizes', '__return_empty_array' );


4

You can perform a combination of things to accomplish a smaller file size. Let me guide you through it. Firstly, you could add custom image sizes and adjust the dimensions to the very smallest for their purpose. Put the following in your functions file: function my_insert_custom_image_sizes( $sizes ) { // get the custom image sizes global ...


3

In this case I would add image size in functions.php which registers new image size in my theme and get the re-sized image. Example: Register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(cropped) } Get custom image size (functions.php) function ...


3

use add_image_size() to define you custom image size 1.register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(hard cropped) } 2.get image in custom image size except featured image of post (functions.php) function ravs_get_custom_image( $featured_img ){ global ...


3

There's a lot going on here. First off, you should store the repeater field image as an ID (that probably requires changing how the subfield's setting and possibly re-uploading some of your images) and then use all the WordPress Core API functions to handle it. (You'll probably cross paths with wp_get_attachment_image_src.) That gets rid of your regex-ing, ...


3

Adding a post thumbnail is pretty easy, open content.php, if you're using excerpts on your homepage find this <?php the_excerpt(); ?> then add this just above that line <?php the_post_thumbnail('thumbnail', 'class=alignleft'); ?> If you're not using excerpts add it above <?php the_content( __( 'Continue reading <span ...


3

Custom Image Sizes Resizing without cropping is already part of the core functionality, via add_image_size(). Note the last parameter: <?php add_image_size( $name, $width, $height, $crop ); ?> The Codex entry describes the $crop parameter as follows: $crop (boolean) (optional) Crop the image or not. False - Soft proportional crop mode ; ...


3

WordPress and TimThumb both use GD to resize images, so quality is going to be similar. GD's resize quality is not as good as Photoshop, you'll notice this especially in fine details. Both WP and TimThumb can be modified to use ImageMagick, WP via a plugin, TimThumb I think requires you edit the code directly, which is not ideal. ImageMagick will give ...


3

WordPress shows whichever image is requested by the function that outputs those images in the template. The presentation of images is entirely up to the theme developer, WordPress doesn't make this decision on its own. For example, the_post_thumbnail function: the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max) ...


3

Users shouldn't have to know anything about image sizes. Just have them upload as-large-as-needed images and your job is to get WordPress to do the rest. When a user uploads an image, WordPress will generate as many images as you've declared with add_image_size(). An example from the codex for your functions.php file: if ( function_exists( ...


3

If I remember right you have to unset all the defaults and add the new Size there: <?php function mxdCustomImageSizes($sizes) { unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); unset( $sizes['full'] ); $myimgsizes = array( 'full-size' => __( 'Full Size' ) ); if( !empty($sizes) ) ...


2

WordPress resizes the image when you upload it. By default it provides 4 sizes of your image (providing your image is bigger than the 'large' size). the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max) the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max) the_post_thumbnail('large'); ...


2

You should be able to do this with the same filter that is talked about here. The full-size images are being kept by WordPress. It's not really a WooCommerce thing. As well as the settings for images in WooCommerce you will also need to set minimum image size in WordPress's Settings>Media... Then this script (see the link above for complete discussion) ...


2

Put this in your theme functions file. It will stop Wordpress from creating anything but the 3 default sizes when uploading. When an image is then requested in a particular size, which is not yet generated, it will be created only that once. add_filter('image_downsize', 'ml_media_downsize', 10, 3); function ml_media_downsize($out, $id, ...


2

Since you know the location of the image on the disk you can use wp_insert_attachment to insert your big image to the media library. By default this will generate also several smaller versions of the big image that you might not need but this is the easiest way to make all the media related plugins to be aware to your image.


2

What you are asking for is called "upscaling images". Wordpress does not do that by default (with reasons). 2 solutions: no physical upscaling: display your images via CSS (and not as IMG html tags), using background-size: cover; a plugin that upscale images. Here is one (untested).


2

Wordpress already does the heavy lifting for you on this. All you need to do is use post thumbnails. If you don't see the featured image meta box on your pages/posts, place the following in your functions.php file. add_theme_support('post-thumbnails'); From there you will need to define a new image size in your functions.php file. ...



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