2

When I click on "Edit" for an image I see the editor and I see the thumbnails on the right, WordPress just won't show me the actual image in the main area.

/wp-admin/admin-ajax.php?action=imgedit-preview&_ajax_nonce=de68a01318&postid=29499&rand=385 (couldn't not find image)

Here is what I have done to try to fix it:

  • Turned off all plugins.
  • Remove my own theme and changed to default theme.
  • Removed all blank lines and whitespaces in /wp-content/themes/name/functions.php + the including files.
  • Checked that php5-gd is installed.
  • Permissions changed to 777 for testing /wp-content/upload/ + sub folders
  • Removed closing ?> tags in /wp-content/themes/name/functions.php + the including files.

Still no preview displayed. What can be the problem?

5 Answers 5

5

By default, wp-config.php might not have a closing tag ?> and this is acceptable and by design. The issue may arise from whitespace in some other .php file. In my case, I had whitespace after the closing tag of my functions.php file for my child theme. Once I removed that whitespace, the images are showing up again and I can crop.

2
  • Brilliant...fixed it for me.
    – P a u l
    May 19, 2020 at 22:15
  • Just an added note. I had a similar issue but actually had a single space BEFORE my opening <?php tag in one of my included files. Fixed the issue, but I never would have found it without this answer.
    – dkeeling
    Jan 11, 2023 at 19:16
4

The preview is now displayed again after I removed empty lines and whitespaces after ?> in my wp-config.php file. That solved the problem.

1

Make sure that not only wp-config.php, and functions.php has no empty lines.

In my case it was one of my custom theme files, which was included with include PHP function inside of single.php file. I found out that in the very beginning of it was few empty lines (before <?php). Removing them solved the "edit image preview" problem, and WP preview started to show image.

It could be real pain to find such files - so if you have SSH access to that server or have all websites source files downloaded locally and you are on Mac, you can run following terminal commands to find out such files (with empty lines at the beginning/end of files):

  1. To search and print a list of all PHP files that BEGIN with an arbitrary empty line:

find ./path-to-source-directory -name "*.php" -type f -size +0 -exec gawk 'STARTFILE{if ($0 == "") print FILENAME}' {} +

  1. To search and print a list of all PHP files that END with an arbitrary empty line:

find ./path-to-source-directory -name "*.php" -type f -size +0 -exec gawk 'FNR==1{if ($0 == "") print FILENAME}' {} +

0

I solved this via a CustomPostType issue. If the CPT you make doesn't have Revisions turned on, then preview can't show the ACF changes.

0

The solution that worked for me I found here: https://wordpress.org/support/topic/could-not-edit-image-unable-to-edit-this-image-localhost/

"Just go to php.ini where xampp is installed, assuming it’s C:\xampp\php by default. Open the file, find the line ;extension=gd and remove that semicolon. Restart xampp server and it should work."

Regards Klaus

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.