Cleanup uploads folder, Media Library db structure
W3-Total Cache has a feature that will scan all your posts and import any external images into the media library and change the paths to the new location. See Screenshot
W3-Total Cache has a feature that will scan all your posts and import any external images into the media library and change the paths to the new location. See Screenshot
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
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
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
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
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
To add the taxonmies from post type post, the default, then it is easy to add taxonmies ‘category’ and ‘tags’ with a small plugin liek the source below. <?php /** * Plugin Name: Attachment Taxonomies * Plugin URI: * Text Domain: attachment_taxonomies * Domain Path: /languages * Description: * Version: 1.0.0 * Author: Frank Bültge … Read more
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
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
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