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

AWS and Wordpress 3.8 #84

Closed lukeshumard closed 10 years ago

lukeshumard commented 10 years ago

I'm using Amazon S3 with Cloudfront (https://github.com/bradt/wp-tantan-s3) with Post Thumbnail Editor, which was working great until I updated to Wordpress 3.8. Now I'm getting 403 errors whenever I try and re-crop an image. What gets returned is... GET http://xxxxxxxxxx-1000x548.jpg?c22e 403 (Forbidden) load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils&ver=3.8:4

...where xxxxxxxxxx is the path to my image, and with the cropped size. However, the new image is never uploaded to S3. The original version is still there.

Any idea why this might be happening?

sewpafly commented 10 years ago

So, does the image get cropped on your system and then fail to upload, or does it never get cropped?

Does anything change if you enable debugging?

lukeshumard commented 10 years ago

Hi, sorry for the delay. I'll put on debugging in a bit and let you know.

I don't think it uploads at all. I don't see it there, but I see the filename when I open the broken image. It looks like... /wp-content/2014/02/filename-size-1393511562.jpg

ph0bos commented 10 years ago

Hi, running WP 3.8.1 with 0.6.1 of the AWS S3/CloudFront plugin (http://wordpress.org/plugins/amazon-s3-and-cloudfront/) and seeing the same issue.

The crops are being performed as the local copies can be found in the wp-content/uploads/* directory.

sewpafly commented 10 years ago

@ph0bos - do you know how to make the s3 plugin recognize a file or which actions it listens on?

ph0bos commented 10 years ago

It appears to hook into the following actions for modifying image assets;

add_filter( 'wp_generate_attachment_metadata', array( $this, 'wp_generate_attachment_metadata' ), 20, 2 );
add_filter( 'delete_attachment', array( $this, 'delete_attachment' ), 20 ); 
sewpafly commented 10 years ago

Yeah, there's the problem. I never call that function/hook. I call wp_update_attachment_metadata (which calls the wp_update_attachment_metadata hook).

Looking through the wordpress code it seems that when wp_gen... is called, it's wrapped in a wp_update... call (see below for grep), so you could change the hook into 'wp_update_attachment_metadata', and it might work just as well..

wp-admin/includes/media.php:        wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
wp-admin/includes/media.php:        wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
wp-admin/includes/image.php:function wp_generate_attachment_metadata( $attachment_id, $file ) {
wp-admin/includes/image.php:            $attach_data = wp_generate_attachment_metadata( $sub_attachment_id, $uploaded['file'] );
wp-admin/includes/image.php:    return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
wp-admin/custom-header.php:             wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
wp-admin/custom-header.php:     wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $cropped ) );
wp-admin/custom-background.php:     wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
wp-includes/class-wp-xmlrpc-server.php:     wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
lukeshumard commented 10 years ago

Awesome, thanks for your help!

tiefenb commented 9 years ago

Hi,

so what was the solution?

tiefenb commented 9 years ago

I have the Problem with Amazon S3 Plugin while saving:

[DEBUG ][2015-10-22T13:48:38+00:00][ PARAMETERS: Array ( [action] => pte_ajax [id] => 29535 [pte-action] => confirm-images [pte-confirm] => Array ( [preview-wide] => IMG_7446-1520x424-1445521709.jpg )

[pte-nonce] => f245f3ce37

) ] [DEBUG ][2015-10-22T13:48:38+00:00][ pte_get_all_alternate_size_information returned: Array ( [preview-wide] => Array ( [width] => 1520 [height] => 424 [crop] => 1 [current] => Array ( [file] => IMG_7446-1520x4241.jpg [width] => [height] => [path] => 2015/10/IMG_7446-1520x4241.jpg [url] => https://files.derbrutkasten.at/2015/10/IMG_7446-1520x4241.jpg )

    )

) ] [DEBUG ][2015-10-22T13:48:38+00:00][ Deleting old thumbnail: https://files.derbrutkasten.at/2015/10/IMG_7446-1520x4241.jpg ] [DEBUG ][2015-10-22T13:48:38+00:00][ Moving '/Applications/MAMP/htdocs/derbrutkasten/public/wp-content/uploads/ptetmp/29535/IMG_7446-1520x424-1445521709.jpg' to 'https://files.derbrutkasten.at/2015/10/IMG_7446-1520x424-1445521709.jpg' ] [DEBUG ][2015-10-22T13:48:39+00:00][ Updating 'preview-wide' metadata: Array ( [file] => IMG_7446-1520x424-1445521709.jpg [width] => [height] => ) ] [WARNUNG][2015-10-22T13:48:39+00:00][ Buffered output:
Warning: rename(): Cannot rename a file across wrapper types in /Applications/MAMP/htdocs/derbrutkasten/public/wp-content/plugins/post-thumbnail-editor/php/functions.php on line 614
]

AsafAzoulay commented 4 years ago

what i need to do for fix this bug?