Skip to content

Instantly share code, notes, and snippets.

@jorenvh
Created December 21, 2016 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorenvh/2e8dd5be53e5e3198f3003d39bd5fa88 to your computer and use it in GitHub Desktop.
Save jorenvh/2e8dd5be53e5e3198f3003d39bd5fa88 to your computer and use it in GitHub Desktop.
Debug output Windows Azure blob storage plugin
[21-Dec-2016 09:28:18 UTC] Array
(
[0] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-includes/plugin.php
[line] => 235
[function] => windows_azure_storage_wp_update_attachment_metadata
[args] => Array
(
[0] => Array
(
[width] => 1792
[height] => 1135
[file] => 2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
)
[1] => 85353
)
)
[1] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-includes/post.php
[line] => 4891
[function] => apply_filters
[args] => Array
(
[0] => wp_update_attachment_metadata
[1] => Array
(
[width] => 1792
[height] => 1135
[file] => 2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
)
[2] => 85353
)
)
[2] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-admin/includes/media.php
[line] => 375
[function] => wp_update_attachment_metadata
[args] => Array
(
[0] => 85353
[1] => Array
(
[width] => 1792
[height] => 1135
[file] => 2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
)
)
)
[3] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-admin/includes/ajax-actions.php
[line] => 2065
[function] => media_handle_upload
[args] => Array
(
[0] => async-upload
[1] =>
[2] => Array
(
)
)
)
[4] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-admin/async-upload.php
[line] => 43
[function] => wp_ajax_upload_attachment
[args] => Array
(
)
)
)
[21-Dec-2016 09:28:18 UTC] 2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png #ORIGINAL RELATIVE FILENAME ON FIRST CALL
[21-Dec-2016 09:28:41 UTC] Array
(
[0] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-includes/plugin.php
[line] => 235
[function] => windows_azure_storage_wp_update_attachment_metadata
[args] => Array
(
[0] => Array
(
[width] => 1792
[height] => 1135
[file] => sites/2/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.3% (2.0 KB)
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 19.4% (7.4 KB)
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 9.2% (8.2 KB)
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 6.0% (7.4 KB) - Previously Optimized
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.9% (48.5 KB)
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
[url] => https://pulsecdn2.azureedge.net/belgium/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[ewww_image_optimizer] => Reduced by 36.0% (82.8 KB)
)
[1] => 85353
)
)
[1] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-includes/post.php
[line] => 4891
[function] => apply_filters
[args] => Array
(
[0] => wp_update_attachment_metadata
[1] => Array
(
[width] => 1792
[height] => 1135
[file] => sites/2/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.3% (2.0 KB)
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 19.4% (7.4 KB)
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 9.2% (8.2 KB)
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 6.0% (7.4 KB) - Previously Optimized
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.9% (48.5 KB)
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
[url] => https://pulsecdn2.azureedge.net/belgium/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[ewww_image_optimizer] => Reduced by 36.0% (82.8 KB)
)
[2] => 85353
)
)
[2] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-content/plugins/ewww-image-optimizer/background.php
[line] => 50
[function] => wp_update_attachment_metadata
[args] => Array
(
[0] => 85353
[1] => Array
(
[width] => 1792
[height] => 1135
[file] => sites/2/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.3% (2.0 KB)
)
[medium] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 19.4% (7.4 KB)
)
[medium_large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-768x486.png
[width] => 768
[height] => 486
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 9.2% (8.2 KB)
)
[large] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-1024x649.png
[width] => 1024
[height] => 649
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 6.0% (7.4 KB) - Previously Optimized
)
[rss-image] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-300x190.png
[width] => 300
[height] => 190
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
[overview-thumbs] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-670x400.png
[width] => 670
[height] => 400
[mime-type] => image/png
[ewww_image_optimizer] => Reduced by 24.9% (48.5 KB)
)
[alm-thumbnail] => Array
(
[file] => Screen-Shot-2015-11-03-at-15.35.07-15-150x150.png
[width] => 150
[height] => 150
[mime-type] => image/png
[ewww_image_optimizer] => No savings
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
[url] => https://pulsecdn2.azureedge.net/belgium/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png
[ewww_image_optimizer] => Reduced by 36.0% (82.8 KB)
)
)
)
[3] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-content/plugins/ewww-image-optimizer/classes/wp-background-process.php
[line] => 300
[function] => task
[class] => EWWWIO_Media_Background_Process
[object] => EWWWIO_Media_Background_Process Object
(
[action:protected] => ewwwio_media_optimize
[start_time:protected] => 1482312499
[cron_hook_identifier:protected] => wp_ewwwio_media_optimize_cron
[cron_interval_identifier:protected] => wp_ewwwio_media_optimize_cron_interval
[prefix:protected] => wp
[identifier:protected] => wp_ewwwio_media_optimize
[data:protected] => Array
(
)
)
[type] => ->
[args] => Array
(
[0] => Array
(
[id] => 85353
[new] => 1
[type] => image/png
[attempts] => 0
)
)
)
[4] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-content/plugins/ewww-image-optimizer/classes/wp-background-process.php
[line] => 446
[function] => handle
[class] => WP_Background_Process
[object] => EWWWIO_Media_Background_Process Object
(
[action:protected] => ewwwio_media_optimize
[start_time:protected] => 1482312499
[cron_hook_identifier:protected] => wp_ewwwio_media_optimize_cron
[cron_interval_identifier:protected] => wp_ewwwio_media_optimize_cron_interval
[prefix:protected] => wp
[identifier:protected] => wp_ewwwio_media_optimize
[data:protected] => Array
(
)
)
[type] => ->
[args] => Array
(
)
)
[5] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-includes/plugin.php
[line] => 600
[function] => handle_cron_healthcheck
[class] => WP_Background_Process
[object] => EWWWIO_Media_Background_Process Object
(
[action:protected] => ewwwio_media_optimize
[start_time:protected] => 1482312499
[cron_hook_identifier:protected] => wp_ewwwio_media_optimize_cron
[cron_interval_identifier:protected] => wp_ewwwio_media_optimize_cron_interval
[prefix:protected] => wp
[identifier:protected] => wp_ewwwio_media_optimize
[data:protected] => Array
(
)
)
[type] => ->
[args] => Array
(
)
)
[6] => Array
(
[file] => /Applications/MAMP/htdocs/project/dev/wp-cron.php
[line] => 117
[function] => do_action_ref_array
[args] => Array
(
[0] => wp_ewwwio_media_optimize_cron
[1] => Array
(
)
)
)
)
[21-Dec-2016 09:28:41 UTC] sites/2/2016/12/Screen-Shot-2015-11-03-at-15.35.07-15.png #ORIGINAL RELATIVE FILENAME ON SECOND CALL
<?php
function windows_azure_storage_wp_update_attachment_metadata( $data, $post_id ) {
//write_log(debug_backtrace());
$default_azure_storage_account_container_name = \Windows_Azure_Helper::get_default_container();
$delete_local_file = \Windows_Azure_Helper::delete_local_file();
$upload_file_name = get_attached_file( $post_id, true );
// If attachment metadata is empty (for video), generate correct blob names.
if ( empty( $data ) || empty( $data['file'] ) ) {write_log('in the if statement (should only be called for videos?');
// Get upload directory.
$upload_dir = wp_upload_dir();
if ( '/' === $upload_dir['subdir']{0} ) {
$upload_dir['subdir'] = substr( $upload_dir['subdir'], 1 );
}
// Prepare blob name.
$relative_file_name = ( '' === $upload_dir['subdir'] ) ?
basename( $upload_file_name ) :
$upload_dir['subdir'] . '/' . basename( $upload_file_name );
} else {
// Prepare blob name.
$relative_file_name = $data['file'];
if(strpos($relative_file_name, 'sites') !== false) {
$segments = explode('/', $relative_file_name);
unset($segments[0]);
unset($segments[1]);
$relative_file_name = implode('/', $segments);
}
}
//...........
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment