可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am having an issue in WordPress admin, where the images are not cropping in WP "edit image" for a site I am creating and I do not know what the cause is.
I've read a few similar topics, but nothing seems to make a dent. I've deactivated all plugins and checked the server, but things seem to be set up just fine.
Can someone possibly steer me in the right direction on how I can get it to work or what might be causing the issue?
回答1:
I faced the same problem and got it solved. This may be a very late response, but can be useful for other people facing this problem.
This is how I resolved it:
Check your functions.php
file. See, if you have the closing tag at the every end of the file.
?>
removing this tag fixed my problem. Also can check out this link. Hope this helps!
回答2:
I had the same issue but the problem was missing the GD library, https://www.digitalocean.com/community/questions/installing-the-gd-image-library
To install (Linux/ Apache2):
sudo apt-get update
sudo apt-get install php5-gd
sudo service apache2 restart
回答3:
None of the above worked for me. So in an effort to give back after taking so much from stackoverflow, here is what I did:
Sometime during the install process a URL rewrite rule was created in IIS. I disabled this rule and then the image crop worked!
回答4:
I found that in my OVH WordPress server, version 4.7.5, imagemagick
was not installed and is required for this function to work properly:
sudo apt-get install imagemagick
sudo service apache2 restart
回答5:
If someone is trying to accomplish this in an AWS Linux Environment, these commands worked for me:
yum install php71-pecl-imagick.x86_64
Of course, you can search for the corresponding imagemagick
package for your environment:
yum search imagemagick
later, don't forget to do a:
service httpd restart
for the changes to take effect on your WP
回答6:
After ruling out several causes
( PHP modules, memory limits ), trying to get useful debugging info, and migrating the site to different hosting, I found that the problem was caused by rewrite rules in the .htaccess
file.
In this case the rules where added by the security plugin All In One WP Security. Maybe, a newer version of the plugin would have fixed it, but I replaced it with another security plugin some time ago.
With removing all rules from the .htaccess
and gradually reintroducing them I
discovered that the specific block of lines in .htaccess
causing the problem was:
# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\\|\.\./|`|='$|=%27$) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|'|\"|%22).* (union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [F]
</IfModule>
回答7:
You may be missing the GD library.
To check that the server has it installed, try php -me
at the command line. Scan for gd module.
If it's missing, get it: sudo apt-get install php7.0-gd
回答8:
This should solve your problem:
- Removed all blank lines and whitespaces in
/wp-content/themes/name/functions.php
+ the including files.
- Removed all blank lines and whitespaces in
/wp-config.php
file
- Check that
php5-gd
is installed.
- Permissions changed to 777 for testing
/wp-content/upload/
+ sub folders
- Removed closing (
?>
) php tags in /wp-content/themes/name/functions.php
+ the including files.
- Turned off all plugins.
- Rename your theme and change to default one.
回答9:
I was not able to crop images, too. The area, where the cropping should show was just blank, instead I got the error message:
Image crop area preview. Requires mouse interaction.
Now, there was also other suspicous things: the media image library showed no thumbnails. When activating developer mode in the browser, I noticed some resources of Wordpress could not load.
Solution: the access rights to /wp-content
were broken, Apache was no longer able to read the files. In my case, recursively changing the access rights of wp-content
folder to rwxr-x---
did solve it.
回答10:
If your WordPress installation hosted on Amazon Red hat, please, do the following:
sudo yum install php-gd
For more check here.
回答11:
I tried everything here, but nothing helped. Eventually, I found an article which mentioned giving IIS_IUSRS
permissions to the WP folder. And that finally got the crop tool working.
回答12:
I re-saved the functions.php
file with file encoding UTF-8
. It worked for me.( Windows 10 )
回答13:
If you've tried just about everything but none of the suggestions work, read on.
I was experiencing this issue on just one site in my dev environment where all other sites were working fine. It ended up being a single included file with UTF-8 BOM header. Removed it and voila!
回答14:
I was having this issue because the Media Previewer/Cropper was attempting to pull the images from http instead of https and my server kept reporting an error 400 when attempting to pull the source images because I do not currently expose traditional non-ssl HTTP.
IE: I'm running on an alternate port and using https://server:9090. When I attempt to crop an image, it tries to load the image via non-ssl http://server:9090/path/to/image.png. It doesn't use the correct protocol and the server responds with a 400 error, thus the cropper is unable to load the image and continue.
In my case, this was happening in the "Customize" section under "Themes". When using the Media Library, it loaded the image correctly over SSL. However, I can't change the image in the customizer without enabling http.