WordPress.org

Making WordPress.org

Changeset 1238


Ignore:
Timestamp:
02/10/2015 12:18:47 AM (5 years ago)
Author:
obenland
Message:

WP.org Themes: Use Photon for theme screenshots.

The Theme Directory feeds off of images to illustrate themes, so we will always
have a sizable footprint. In listings, screenshots are retina, so four times
the size they could be, on single they are over 700px wide. No reason not to
try our best to keep it managable though!

Using Photon will cut page weight to about half of what it is now.
We're adjusting the size to only what we need and remove all meta data.

See https://wordpress.slack.com/archives/meta/p1423518323000926

Fixes #845.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/content-single.php

    r1188 r1238  
    1 <?php global $theme; ?>
     1<?php
     2    global $theme;
     3    $theme = wporg_themes_photon_screen_shot( $theme );
     4?>
    25<div class="theme-wrap">
    36    <div class="theme-about">
     
    1013
    1114        <div class="theme-screenshots">
    12             <div class="screenshot"><?php the_post_thumbnail(); ?></div>
     15            <div class="screenshot"><?php echo esc_url( $theme->screenshot_url . '?w=613&strip=all' ); ?></div>
    1316
    1417            <div class="theme-actions">
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/content.php

    r1147 r1238  
    1 <?php global $theme; ?>
     1<?php
     2    global $theme;
     3    $theme = wporg_themes_photon_screen_shot( $theme );
     4?>
    25<article id="post-<?php echo $theme->slug; ?>" class="theme hentry">
    36    <div class="theme-screenshot">
    4         <img src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="">
     7        <img src="<?php echo esc_url( $theme->screenshot_url . '?w=286&strip=all' ); ?>" alt="">
    58    </div>
    69    <a class="more-details url" href="<?php echo esc_url( home_url( $theme->slug . '/' ) ); ?>" rel="bookmark"><?php _ex( 'More Info', 'theme' ); ?></a>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php

    r1212 r1238  
    241241
    242242    foreach ( $api->themes as &$theme ) {
    243         $theme->name        = wp_kses( $theme->name,        $themes_allowedtags );
    244         $theme->author      = wp_kses( $theme->author,      $themes_allowedtags );
    245         $theme->version     = wp_kses( $theme->version,     $themes_allowedtags );
    246         $theme->description = wp_kses( $theme->description, $themes_allowedtags );
    247         $theme->num_ratings = number_format_i18n( $theme->num_ratings );
    248         $theme->preview_url = set_url_scheme( $theme->preview_url );
     243        $theme->name           = wp_kses( $theme->name,        $themes_allowedtags );
     244        $theme->author         = wp_kses( $theme->author,      $themes_allowedtags );
     245        $theme->version        = wp_kses( $theme->version,     $themes_allowedtags );
     246        $theme->description    = wp_kses( $theme->description, $themes_allowedtags );
     247        $theme->num_ratings    = number_format_i18n( $theme->num_ratings );
     248        $theme->preview_url    = set_url_scheme( $theme->preview_url );
     249        wporg_themes_photon_screen_shot( $theme );
    249250    }
    250251
     
    264265    }
    265266
    266     $theme->name        = wp_kses( $theme->name,        $themes_allowedtags );
    267     $theme->author      = wp_kses( $theme->author,      $themes_allowedtags );
    268     $theme->version     = wp_kses( $theme->version,     $themes_allowedtags );
    269     $theme->description = wp_kses( $theme->description, $themes_allowedtags );
    270     $theme->num_ratings = number_format_i18n( $theme->num_ratings );
    271     $theme->preview_url = set_url_scheme( $theme->preview_url );
     267    $theme->name           = wp_kses( $theme->name,        $themes_allowedtags );
     268    $theme->author         = wp_kses( $theme->author,      $themes_allowedtags );
     269    $theme->version        = wp_kses( $theme->version,     $themes_allowedtags );
     270    $theme->description    = wp_kses( $theme->description, $themes_allowedtags );
     271    $theme->num_ratings    = number_format_i18n( $theme->num_ratings );
     272    $theme->preview_url    = set_url_scheme( $theme->preview_url );
     273    wporg_themes_photon_screen_shot( $theme );
    272274
    273275    wp_send_json_success( $theme );
     
    275277add_action( 'wp_ajax_theme-info',        'wporg_themes_theme_info' );
    276278add_action( 'wp_ajax_nopriv_theme-info', 'wporg_themes_theme_info' );
     279
     280/**
     281 * Photon-ifies the screen shot URL.
     282 *
     283 * @param object $theme
     284 * @return object
     285 */
     286function wporg_themes_photon_screen_shot( $theme ) {
     287    if ( preg_match( '/screenshot.(jpg|jpeg|png|gif)/', $theme->screenshot_url, $match ) ) {
     288        $theme->screenshot_url = sprintf( 'https://i0.wp.com/themes.svn.wordpress.org/%1$s/%2$s/%3$s',
     289            $theme->slug,
     290            $theme->version,
     291            $match[0]
     292        );
     293    }
     294    return $theme;
     295}
    277296
    278297/**
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme-single.php

    r1088 r1238  
    1616                <div class="theme-screenshots">
    1717                    <# if ( data.screenshot_url ) { #>
    18                         <div class="screenshot"><img src="{{ data.screenshot_url }}" alt=""/></div>
     18                        <div class="screenshot"><img src="{{ data.screenshot_url }}?w=732&strip=all" alt=""/></div>
    1919                    <# } else { #>
    2020                        <div class="screenshot blank"></div>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme.php

    r1221 r1238  
    22    <# if ( data.screenshot_url ) { #>
    33    <div class="theme-screenshot">
    4         <img src="{{ data.screenshot_url }}" alt="" />
     4        <img src="{{ data.screenshot_url }}?w=572&strip=all" alt="" />
    55    </div>
    66    <# } else { #>
Note: See TracChangeset for help on using the changeset viewer.