admin管理员组

文章数量:1418103

I've specified some custom image sizes each with a non-default crop position (e.g. top-center). However, when I use wp_get_attachment_image and specify size to be one that I defined, I get a correctly sized image with an incorrect crop position.

It turns out that the image URI is of the form /wp-content/uploads/2017/11/myimage.jpg?resize=293%2C160, even though I definitely have the proper .jpg image with correct crop position. Interestingly, though, wp_get_attachment_metadata returns the correct, static URI for the given image size.

Why is WordPress deferring to dynamic resizing? Is this somehow prefereble? In any case, how can I disable it?

I've specified some custom image sizes each with a non-default crop position (e.g. top-center). However, when I use wp_get_attachment_image and specify size to be one that I defined, I get a correctly sized image with an incorrect crop position.

It turns out that the image URI is of the form https://i1.wp/example/wp-content/uploads/2017/11/myimage.jpg?resize=293%2C160, even though I definitely have the proper https://example/wp-content/uploads/2017/11/myimage-293x160.jpg image with correct crop position. Interestingly, though, wp_get_attachment_metadata returns the correct, static URI for the given image size.

Why is WordPress deferring to dynamic resizing? Is this somehow prefereble? In any case, how can I disable it?

Share Improve this question asked Nov 2, 2017 at 0:20 Joel ChristophelJoel Christophel 1336 bronze badges 4
  • 3 Are you on a wp site? Or have Jetpack photon turned on? Standard WP doesn't generate images on the fly via URL, the images are just served straight off of the file system – Tom J Nowell Commented Nov 2, 2017 at 0:47
  • 1 Turns out that Jetpack came preinstalled, and with Photon enabled. One flick of a toggle switch and my problem is solved. Thanks much! Turn your comment into a question for reputation if you so please. – Joel Christophel Commented Nov 2, 2017 at 0:54
  • 1 Into an *answer haha – Joel Christophel Commented Nov 2, 2017 at 1:07
  • Great answer Tom J Nowell: In my case I had to switch off the option "Speed up your site > Serve images from our servers" in the JetPack settings – bgx Commented Jun 5, 2018 at 9:52
Add a comment  | 

1 Answer 1

Reset to default -1

Please try this plugin for regenerate image thumbnail and then try to display it.Thumnail regenerate plugin

本文标签: Stop WordPress from cropping images using url parameters