Support » Fixing WordPress » WP_Image_Editor Saving

  • I have the following code to resize an image uploaded from a Gravity Forms form.

    //resize images uploaded to Gravity Form
    $url =  $entry[3];
    $parsed_url = parse_url($url);
    $path = $_SERVER['DOCUMENT_ROOT'] . $parsed_url['path'];
    
    $image = wp_get_image_editor($path);
    if ( ! is_wp_error( $image ) )
    {
    	// Desired dimensions.  false indicates not to crop image.
    	$result = $image->resize( 610,540, false );
    	$result = $image->save( $path );
    }

    I am trying to resize the image to reduce the size of photos that people are uploading to the website. When the image is saved the dimensions are added to the end of the filename (e.g. PICT1769-610×457.jpg). Is this normal behavior. I would like to replace the original image (ie. PICT1769.jpg).

    I tried replacing $path in $image->save with ‘new-upload.jpg’ and the photo was still saved as ‘PICT1769-610×457.jpg’. I searched the whole site and couldn’t find ‘new-upload.jpg’ anywhere.

    Does anyone know how I can get the resized image to overwrite the original and as a side why it wouldn’t be saving using the given filename?

    Many Thanks!!

  • The topic ‘WP_Image_Editor Saving’ is closed to new replies.