Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Am/backport 2024 commits #1

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions windows-azure-storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,14 @@ function windows_azure_storage_wp_generate_attachment_metadata( $data, $post_id

try {
$post_array = wp_unslash( $_POST );
$post_array = wp_parse_args( $post_array, array(
'item_id' => $post_array['name'] . '_' . $post_array['_wpnonce'],
) );
$azure_progress_key = 'azure_progress_' . sanitize_text_field( trim( $post_array['item_id'] ) );
$current = 0;
$item_id = !empty($post_array) ?
$post_array['name'] . '_' . $post_array['_wpnonce'] :
$file_path;
$post_array = wp_parse_args($post_array, array(
'item_id' => $item_id,
));
$azure_progress_key = 'azure_progress_' . sanitize_text_field(trim($post_array['item_id']));
$current = 0;
// Get full file path of uploaded file.
$data['file'] = $upload_file_name;

Expand Down Expand Up @@ -565,6 +568,10 @@ function windows_azure_storage_wp_generate_attachment_metadata( $data, $post_id
}
}

if (empty($thumbnails) && $mime_type !== 'application/pdf') {
throw new Exception('Dotdigital image storage debug: No thumbnails generated for ' . $file_path);
}

delete_post_meta( $post_id, 'windows_azure_storage_info' );

add_post_meta( $post_id, 'windows_azure_storage_info', array(
Expand All @@ -577,6 +584,8 @@ function windows_azure_storage_wp_generate_attachment_metadata( $data, $post_id

} catch ( Exception $e ) {
echo '<p>', sprintf( __( 'Error in uploading file. Error: %s', 'windows-azure-storage' ), esc_html( $e->getMessage() ) ), '</p>';
error_log(esc_html( $e->getMessage() ) );
error_log($e->getTraceAsString());
}

return $data;
Expand Down