Skip to content

Commit

Permalink
fix path issue with override container
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Solar committed Jul 17, 2024
1 parent 9024dff commit d1f9762
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions windows-azure-storage-util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions windows-azure-storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit d1f9762

Please sign in to comment.