Each custom image size in custom upload directory?

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 … Read more

Reject upload of wrong-sized images using the Media Uploader

In your handler, if you set ‘error’, the error message will be displayed and will cancel the upload add_filter( ‘wp_handle_upload_prefilter’, ‘custom_upload_filter’ ); function custom_upload_filter( $file ) { $image_info = getimagesize( $file[‘tmp_name’] ); $image_width = $image_info[0]; $image_height = $image_info[1]; if ( $image_with !== 800 || $image_height !== 600 ) { $file[‘error’] = __( ‘Images must be … Read more

Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions

This isn’t a really good solution since it’s a newer CSS solution and it’s only working in 78.9% of users browsers, but there are a few polyfills that can overcome that object-fit-images and fitie img { display: block; overflow: hidden; width: 400px; height: 400px; -o-object-fit: cover; object-fit: cover; } Ideally it would be better if … Read more

How to Dynamically Resize WordPress Image On-The-Fly (custom field/theme option)

Re-size WordPress images on the fly using built-in WordPress functions. Use the vt_resize function to dynamically re-size WordPress images located in a custom field, featured image, uploads directory, NextGen Gallery WordPress plugin, or even an external link to an offsite image. It is very simple to use, just copy/paste the code below into your WordPress … Read more

How to disable generation of default image sizes for some custom post types?

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): function do_your_stuff( $data, $attachment_id … Read more

removing inline styles from wp-caption div

To remove the inline width in a clean PHP-way could be done with a filter, as described in the source code: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/media.php#L1587 Returning a zero (or false) will remove it: add_filter( ‘img_caption_shortcode_width’, ‘__return_false’ );

How to scale up featured post thumbnail?

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 ) return null; // let the wordpress … Read more

Get the first image from post content (eg.: hotlinked images)

If you want display an image that is inserted into your content (a hotlinked image, for example), you must use a function like this (source): add in functions.php: function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş