sewpafly / post-thumbnail-editor

Wordpress Plugin to manually edit post thumbnails
http://wordpress.org/extend/plugins/post-thumbnail-editor/
32 stars 18 forks source link

Thumbnail editing page missing source image for cropping #93

Closed kimbo6365 closed 10 years ago

kimbo6365 commented 10 years ago

Hi @sewpafly,

I've just pushed the newest version of this plugin up to my production servers, and (of course), now I'm seeing this issue that has been frequently reported on the plugin's WP support page @ http://wordpress.org/support/plugin/post-thumbnail-editor

I'm running WordPress 3.7.1 and Post Thumbnail Editor 2.3.0

I didn't notice this issue earlier because it only rarely occurs on my local and testing environments. However, it occurs about 70% of the time on my Live environment. If I wildly press F5 on several pages in my local or testing environments, I can get this problem to occur, maybe 5% of the time. I would expect that it's just the extra traffic on my live page that causes it to occur more frequently.

I'm using Chrome v33, but I've also been able to reproduce the same pattern in Firefox 28, IE 11, and Opera 20. I'm quite sure that it has absolutely nothing to do with the browser, but I've done my due diligence as a tester :)

When the error occurs, the visual manifestation is intermittent:

Maybe 20% of the time when the error occurs, I see a big black box where the image should be and the browser's missing image icon displayed in the center of the box. Weirdly enough, in these cases, if I inspect that area, the #pte-preview img contains the image, but the inline CSS is still set to display: none; The height and width attributes of the image are correct. pte-missing-image-icon

The rest of the time, which is around 80% of the time that the error occurs, when I load the thumbnail editing page, no image is shown at all. The #pte-preview img has the following inline style: display: none; height: 0px; width: 0px; pte-missing-image

In these instances with no image at all, I see this in the console log:

Resource interpreted as Image but transferred with MIME type text/html: "http://www.[redacted].com/wp-admin/admin-ajax.php?action=pte_imgedit_preview&_ajax_nonce=da7b23bd49&postid=5919&rand=39806". --> upload.php?page=pte-edit&pte-id=5919:397 Resource interpreted as Image but transferred with MIME type text/html: "http://www.[redacted].com/wp-admin/admin-ajax.php?action=pte_imgedit_preview&_ajax_nonce=da7b23bd49&postid=5919&rand=39806". --> jquery.Jcrop.min.js:11 a.Jcrop --> jquery.Jcrop.min.js:11 (anonymous function) --> jcrop-api.coffee:88 i.execCb --> require.js:29 X.check --> require.js:18 (anonymous function) --> require.js:23 (anonymous function) --> require.js:8 (anonymous function) --> require.js:23 y --> require.js:7 X.emit --> require.js:23 X.check --> require.js:19 X.enable --> require.js:23 X.init --> require.js:17 D --> require.js:14 i.completeLoad --> require.js:28 i.onScriptLoad --> require.js:29

In the network tab, this resource has an empty response. If I open this URL in the browser, I get a "-1" response ~70% of the time and my image the rest of the time. I expect the "-1" response is why the "Resource interpreted as Image but transferred with MIME type text/html" warning is triggered.

I've read through the support threads over at WordPress, and I haven't found a solution there. When I open the Media in the native WP media editor, the images load 100% of the time without problems. I've also gone through and made sure there are no empty lines at the end of any php files.

Any ideas? If you need any information from me, I'd be happy to help.

sewpafly commented 10 years ago

I'm going to have a fix for this shortly. I believe that the problem occurs because the image is built on the fly and there must be some sort of race condition. It's difficult for me to test because it almost never happens for me.

Solutions that I have heard:

When I have a fix, I'll report it here and hopefully you can help me test it.

kimbo6365 commented 10 years ago

Thanks for your quick response and suggested workarounds!

I have tried all three, and unfortunately, none of them resolve the problem. It's really strange how I'm only able to reproduce the problem around 10% of the time on my local and testing environments, but it occurs around 70% of the time on my live environment.

My speculation is that it's just the amount of traffic that causes the increase in frequency on my live system. On my local or testing environments, I have to open 9 or 10 tabs and just continuously refresh them like mad to get the problem to occur at all. I think your idea about the problem lying in how the image is built on-the-fly has got to be part of the problem.

If there's any way that I can help you out with the debugging or testing, just let me know--I'd be happy to help! I'm a big fan of the plugin :)

sewpafly commented 10 years ago

I have something I would like you to try. Enable debugging (this loads the original javascript instead of the minified stuff) and then modify js/csmain.coffee. Change the timeout = 3000 to something like 10000 (10 seconds) and see if that makes a difference.

If that still doesn't work, uncomment the line that says #console.log document.readyState and after loading the page, check your javascript console again. Thanks.

sewpafly commented 10 years ago

Closing with preliminary fix: 43ffefe7e40ae99b7c281634963f1fd1b5ee51fa