Make WordPress Core

Ticket #34109: 34109_attachments-ssl.diff

File 34109_attachments-ssl.diff, 1.3 KB (added by alexdelgado, 9 years ago)

patch for serving attachments over ssl

  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 249e685..39aee15 100644
    function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon 
    763763                }
    764764
    765765                if ( $src && $width && $height ) {
     766                        $src = set_url_scheme( $src );
    766767                        $image = array( $src, $width, $height );
    767768                }
    768769        }
    function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac 
    11561157        $srcset = '';
    11571158
    11581159        foreach ( $sources as $source ) {
    1159                 $srcset .= $source['url'] . ' ' . $source['value'] . $source['descriptor'] . ', ';
     1160                $srcset .= set_url_scheme( $source['url'] ) . ' ' . $source['value'] . $source['descriptor'] . ', ';
    11601161        }
    11611162
    11621163        return rtrim( $srcset, ', ' );
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index bb7e37a..5507b15 100644
    function wp_get_attachment_url( $post_id = 0 ) { 
    49804980                $url = get_the_guid( $post->ID );
    49814981        }
    49824982
    4983         // On SSL front-end, URLs should be HTTPS.
    4984         if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) {
    4985                 $url = set_url_scheme( $url );
    4986         }
     4983        // Always check if HTTPS should be set
     4984        $url = set_url_scheme( $url );
    49874985
    49884986        /**
    49894987         * Filter the attachment URL.