Replace original image, WP image editor

What you want is probably something like this. You need to manually unlink the original image including added sizes. The WP image editor automatically creates a new image with a new name as you mentioned but not others added through add_image_size() function. regenerate_added_sizes() in the code below does exactly that: function replace_original_images( $override, $filename, $image, … Read more

Woocommerce featured image of page – not product

Thanks to you I tried this on my functions.php It worked, but also had to get the ID of the page, in my case 4. add_action( ‘woocommerce_before_main_content’, ‘woocommerce_category_image’, 2 ); function woocommerce_category_image() { if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_term_meta( $cat->term_id, ‘thumbnail_id’, true ); $image = wp_get_attachment_url( $thumbnail_id ); if … Read more

If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?

Here’s what you can do: Delete the Old Thumbnails Download and install the Thumbnail Cleaner plugin. This plugin will delete all of your current thumbnails. You can do this manually by writing a PHP snippet that detects thumbnails and deletes them, but it’s not really that necessary. Resize the Original Images Once you have deleted … Read more

Remove Size images without use

Yes, just search for a specific image size within the theme files. The text editors like Atom, BBEdit, Notepad++ allows to do that. P.S. You can find image size name in add_image_size() function argument.

Make medium_large images available to insert into post

since I’m using a size already generated by WP, I just needed to add: add_filter( ‘image_size_names_choose’, ‘fresh_custom_sizes’ ); function fresh_custom_sizes( $sizes ) { return array_merge( $sizes, array( ‘medium_large’ => __( ‘Medium Large’ ), ) ); }

Inserting HTML tag with ACF into shortcode

You have to use do_shortcode() to execute shortcodes in your string Full code should be like that <?php function my_shortcode( $atts ) { $atts = shortcode_atts( array( ‘post_id’ => ”, // Default value. ), $atts ); $output=”https://wordpress.stackexchange.com/questions/291524/[acf field=”image” post_id=”” . $atts[‘post_id’] . ‘”]’; $output = do_shortcode( $output ); $output=”<img src=”” . $output . ‘” />’; … Read more

Automatically wrap multiple images in div

This is a function I use to add a wrapper to each image. I know it’s not 100% what you want, but I thought this might give you a handle to work from. function add_image_wrapper( $content ) { $content = preg_replace_callback( ‘/<img[^>]+>/im’, function ( $matches ) { $image = $matches[0]; $classes = array(); preg_match( ‘/class=”align([^”]+)”/im’, … Read more

Changing path for media upload folder in wordpress multisite

This has been answered Hook filter to change wp_upload_dir() path in multisite , including code to hook into the upload_dir hook. Note that there is a setting in wp-config.php for the ‘base’ upload folder define(‘UPLOADS’, ‘wp-content/myimages’); So with this code, the uploads folder is wp-content/myimages. But, that changes the place WP looks for the media, … Read more

upload featured image in custom post type from frontend

You are using the wp_insert_attachment() function, which states the following in the Codex: This function is part of the low-level API used by WordPress for handling attachments. To perform the entire attachment upload and insertion process at once, you will want to use media_handle_upload() instead in most cases. So to automatically generate the image resizes … Read more