Changeset 1705 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-showcase/functions.php
- Timestamp:
- 07/05/2015 07:26:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-showcase/functions.php
r1474 r1705 31 31 } 32 32 33 if ( !empty( $_COOKIE['devicePixelRatio'] ) && $_COOKIE['devicePixelRatio'] >= 1.5 ) {34 $width = $width * 2;35 }36 37 33 if ( '' != $width ) { 38 34 $screenshot .= '?w=' . $width; … … 46 42 return $screenshot; 47 43 } 44 } 45 46 // build the whole img tag properly for the screenshot, with srcset support 47 function site_screenshot_tag( $width = '', $classes='screenshot' ) { 48 global $post; 49 50 $screenshot = get_post_meta($post->ID, 'screenshot', true); 51 if ( empty( $screenshot ) ) { 52 $screenshot = 'https://wordpress.com/mshots/v1/http%3A%2F%2F' . get_site_domain( true, false ); 53 $srcset = $screenshot; 54 } 55 56 if ( '' != $width ) { 57 $screenshot .= '?w=' . $width; 58 $srcset .= '?w=' . $width*2; 59 } 60 61 // mshot images have a 4/3 ratio 62 $height = (int)( $width * (3/4) ); 63 64 $img = "<img src='{$screenshot}' srcset='$srcset 2x' width='{$width}' height='{$height}' alt='". the_title_attribute(array('echo'=>false)) . "' class='{$classes}' />"; 65 66 echo $img; 48 67 } 49 68
Note: See TracChangeset
for help on using the changeset viewer.