Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
images were overwritten by wp_generate_attachment_metadata
  • Loading branch information
demmel committed Apr 19, 2016
1 parent 611029c commit 69fdc74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/ManualImageCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ private function filterPostData() {
* Callback function for plugin: amazon-s3-and-cloudfront
*/
function get_attached_file_copy_back_to_local( $copy_back_to_local, $file, $attachment_id ) {
return true; // we want the image on the server
if ( !file_exists($file)) {
return true; // we want the image on the server
} else {
return false;
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/ManualImageCropEditorWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public function renderWindow() {
add_filter( 'as3cf_get_attached_file_copy_back_to_local', 'ManualImageCrop::get_attached_file_copy_back_to_local', 10, 3 );

// function get_attached_file is called to trigger the hook above
$metaData = wp_generate_attachment_metadata($postId,get_attached_file($postId));
} else {
$metaData = wp_get_attachment_metadata($postId);
get_attached_file($postId);
}

$metaData = wp_get_attachment_metadata($postId);

if (!$metaData) {
echo json_encode (array('status' => 'error', 'message' => 'could not get metadata for attachement(' . $postId . ') try reuploading the file' ) );
exit;
Expand Down

0 comments on commit 69fdc74

Please sign in to comment.