How to show all available images in WP’s media library when using the Polylang plugin?

From this post at wordpress.org/support, the user Chrystl points out: If don’t need to translate your media titles, uncheck this option: In Languages > Settings tab > Media: “Activate languages and translations for media”. And you will access to your entire library by clicking on “Add media” and “Set featured image”. And that indeed did … Read more

Custom post type with a forced fixed aspect ratio image crop

Don, You will have to add support for thumbnails in your functions.php/plugin-file.php //Add Support for Thumbs if ( function_exists( ‘add_theme_support’ ) ) { add_theme_support( ‘post-thumbnails’ ); set_post_thumbnail_size( 960, 276, true ); // default Post Thumbnail dimensions } //Add Thumbnail sizes if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘large-thumb’, 960, 276, true ); //960 pixels … Read more

Set default image link target in Gutenberg image block

This was (finally) fixed to Gutenberg (and will be applicable for both the image and the gallery blocks); and will add an option to WordPress options’ database table. this was done in https://github.com/WordPress/gutenberg/pull/25578 and https://github.com/WordPress/gutenberg/pull/25582 It’ll be added to WordPress 5.6 but it’s already available in the Gutenberg plugin. To link the image to the … Read more

How can you set maximum width for original images?

I was able to solve it using the following code: function my_handle_upload ( $params ) { $filePath = $params[‘file’]; if ( (!is_wp_error($params)) && file_exists($filePath) && in_array($params[‘type’], array(‘image/png’,’image/gif’,’image/jpeg’))) { $quality = 90; list($largeWidth, $largeHeight) = array( get_option( ‘large_size_w’ ), get_option( ‘large_size_h’ ) ); list($oldWidth, $oldHeight) = getimagesize( $filePath ); list($newWidth, $newHeight) = wp_constrain_dimensions( $oldWidth, $oldHeight, $largeWidth, … Read more

Add media with WP-Rest-API v2

SO! This is fun. Keep in mind the WP-API is still very, very much a work-in-progress. Content-Disposition I found an issue reported on the WP-API issue queue about Content-Disposition. This is a required header for posting new media content and there are some very, very strict requirements when it comes to providing this in the … Read more

How to make a image-size selected by default in Media upload – WP v3.5

Try this out. Your add_filter()’s second argument is a function, that will affect the current option via a return: function theme_default_image_size() { return ‘custom-image-size-2’; } add_filter( ‘pre_option_image_default_size’, ‘theme_default_image_size’ ); You could also look into the pre_update_option_{$option} filter, and update the value once, so you don’t need to run this filter every time (may save 0.01s, … Read more

How to trigger a refresh in the media modal

You can checkout this link https://codex.wordpress.org/Javascript_Reference/wp.media jQuery(function($){ // Set all variables to be used in scope var frame, metaBox = $(‘#meta-box-id.postbox’), // Your meta box id here addImgLink = metaBox.find(‘.upload-custom-img’), delImgLink = metaBox.find( ‘.delete-custom-img’), imgContainer = metaBox.find( ‘.custom-img-container’), imgIdInput = metaBox.find( ‘.custom-img-id’ ); // ADD IMAGE LINK addImgLink.on( ‘click’, function( event ){ event.preventDefault(); // If … 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

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