diff --git a/windows-azure-storage-util.php b/windows-azure-storage-util.php index 3f9feee..27187fa 100644 --- a/windows-azure-storage-util.php +++ b/windows-azure-storage-util.php @@ -315,7 +315,7 @@ protected static function _maybe_rewrite_cname( $cname ) { public static function get_storage_url_base( $append_container = true ) { $azure_storage_account_name = \Windows_Azure_Helper::get_account_name(); $default_azure_storage_account_container_name = \Windows_Azure_Helper::get_default_container(); - $azure_storage_override_container_path = \Windows_Azure_Helper::get_azure_storage_override_container_path(); + $azure_storage_override_container_path = \Windows_Azure_Helper::get_azure_storage_override_container_path(); /** * Filter the blob URL protocol to force a specific one. * @@ -337,11 +337,12 @@ public static function get_storage_url_base( $append_container = true ) { } // Get CNAME if defined. - $cname = \Windows_Azure_Helper::get_cname(); + $cname = \Windows_Azure_Helper::get_cname(); + $maybe_override_container_name = ! empty( $azure_storage_override_container_path ) ? $azure_storage_override_container_path : $default_azure_storage_account_container_name; if ( ! empty( $cname ) ) { $url = sprintf( '%1$s/%2$s', $cname, - $append_container = ! empty( $azure_storage_override_container_path ) ? $azure_storage_override_container_path : $default_azure_storage_account_container_name + $append_container = $append_container ? $maybe_override_container_name : '' ); } else { $blob_storage_host_name = \Windows_Azure_Helper::get_hostname(); diff --git a/windows-azure-storage.php b/windows-azure-storage.php index fe62f00..73db609 100644 --- a/windows-azure-storage.php +++ b/windows-azure-storage.php @@ -874,14 +874,17 @@ function windows_azure_storage_plugin_menu() { * @return array The filtered $sources array. */ function windows_azure_storage_wp_calculate_image_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { - $media_info = get_post_meta( $attachment_id, 'windows_azure_storage_info', true ); + $media_info = get_post_meta( $attachment_id, 'windows_azure_storage_info', true ); + $default_azure_storage_account_container_name = \Windows_Azure_Helper::get_default_container(); + $azure_storage_override_container_path = \Windows_Azure_Helper::get_azure_storage_override_container_path(); + $maybe_override_container_path = ! empty( $azure_storage_override_container_path ) ? $azure_storage_override_container_path : $default_azure_storage_account_container_name; // If a CNAME is configured, make sure only 'http' is used for the protocol. $azure_cname = \Windows_Azure_Helper::get_cname(); $esc_url_protocols = ! empty( $azure_cname ) ? array( 'https', 'http', '//' ) : null; if ( ! empty( $media_info ) ) { - $base_url = trailingslashit( WindowsAzureStorageUtil::get_storage_url_base( false ) . $media_info['container'] ); + $base_url = trailingslashit( WindowsAzureStorageUtil::get_storage_url_base( false ) . $maybe_override_container_path ); foreach ( $sources as &$source ) { $img_filename = substr( $source['url'], strrpos( $source['url'], '/' ) + 1 );