Title: Can&#8217;t access image uploaded with WP_Image_Editor using php file_exist function.
Last modified: August 27, 2020

---

# Can’t access image uploaded with WP_Image_Editor using php file_exist function.

 *  Resolved [iamrahul95](https://wordpress.org/support/users/iamrahul95/)
 * (@iamrahul95)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/cant-access-image-uploaded-with-wp_image_editor-using-php-file_exist-function/)
 * Hi,
    I am developing a podcast theme where i have a form that allows the user
   to upload their podcast cover arts. The Podcast cover art’s dimension should 
   fall under 1400×1400 and 3000×3000 since we are following iTune’s regulations.
   Since such big files will impact the page load speed of the site i wanna resize
   the uploaded image to a smaller size, say 250×250 so that we can use that to 
   display on our web pages. I have used `WP_Image_Editor::resize` function to resize
   the uploaded image and `WP_Image_Editor::save` function to save it. It actually
   worked. I now have two different images with two different dimensions. Since 
   a lot of our user’s have already posted their podcast with the bigger images,
   i simply cannot exclusively show the compressed version. Instead i wanna check
   if a compressed version exists or not and show the image accordingly. I have 
   used PHP’s `file_exists` function to check for the compressed version of the 
   images. But it seems, it always returns false in the case of compressed images.
   But i can access it through the browser by typing in the full address.
 *     ```
       file_exists('path/to/original_image'); = true
       file_exists('path/to/compressed_image'); = false
       ```
   
 * I have used `wp_handle_upload()` to upload the original image but `wp_image_editor`
   class to resize and save the compressed one. So there must be something different
   with these two functions that’s causing this issue.
 * Do you guys have any idea, how i can get over this ? Any help would be greatly
   appreciated.
 * Thanks in advance.
    -  This topic was modified 5 years, 8 months ago by [iamrahul95](https://wordpress.org/support/users/iamrahul95/).
    -  This topic was modified 5 years, 8 months ago by [iamrahul95](https://wordpress.org/support/users/iamrahul95/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/cant-access-image-uploaded-with-wp_image_editor-using-php-file_exist-function/#post-13323397)
 * You might be better off (especially if this is really a theme instead of a plugin)
   using the WordPress functions. Call `add_image_size()` and have the user add 
   the image as an attachment (you can call `wp_insert_attachment()`). WordPress
   will do the generation of the sizes, and if the attachment is added to the content,
   will also output the `srcset` attribute on the image so that the correct size
   for the user’s device is used by the browser.
    And, with the new image size added,
   you can run [Regenerate Thumbnails](https://wordpress.org/plugins/search/regenerate+thumbnails/)
   to fix all the old ones.
 * [https://developer.wordpress.org/reference/functions/add_image_size/](https://developer.wordpress.org/reference/functions/add_image_size/)
   
   [https://developer.wordpress.org/reference/functions/wp_insert_attachment/](https://developer.wordpress.org/reference/functions/wp_insert_attachment/)
 *  Thread Starter [iamrahul95](https://wordpress.org/support/users/iamrahul95/)
 * (@iamrahul95)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/cant-access-image-uploaded-with-wp_image_editor-using-php-file_exist-function/#post-13326168)
 * Hi, I was un-aware of those two functions. Thank you for that. That would help
   me to reduce the compression process that i’m doing right now i think.
 * Actually i found out the actual issue in my case, i was passing url to the wp_image_editor
   function instead of the file path. (Thanks to the thread i opened [here](https://wordpress.stackexchange.com/questions/373844/unable-to-check-if-image-uploaded-by-wp-image-editor-exists-using-file-exists-fu))
   Once i pass the file path it is working. But the weird thing is that, even if
   i pass the wrong parameter to the wp_image_editor function the image seems to
   be uploaded somewhere as i am able to access it from the browser. But if i look
   for it through the FTP i can’t see it.
 * Seems it is because of anything from the WordPress Hosting environment. That 
   a whole new different discussion i suppose.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can’t access image uploaded with WP_Image_Editor using php file_exist
function.’ is closed to new replies.

## Tags

 * [file_exists](https://wordpress.org/support/topic-tag/file_exists/)
 * [wp_handle_upload](https://wordpress.org/support/topic-tag/wp_handle_upload/)
 * [wp_image_editor](https://wordpress.org/support/topic-tag/wp_image_editor/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [iamrahul95](https://wordpress.org/support/users/iamrahul95/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/cant-access-image-uploaded-with-wp_image_editor-using-php-file_exist-function/#post-13326168)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
