Plugin Directory

Changeset 796797

Timestamp:
10/31/2013 07:07:06 PM (11 years ago)
Author:
jshreve
Message:

Provide multiple fallbacks for OG. Merge with WordPress.com

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/functions.opengraph.php

    r796013 r796797  
    8888   
    8989    // secure_urls need to go right after each og:image to work properly so we will abstract them here
    90     $secure = $tags['og:image:secure_url'];
     90    $secure = $tags['og:image:secure_url'];
    9191    unset( $tags['og:image:secure_url'] );
    9292    $secure_image_num = 0;
     
    168168    }
    169169
    170     // Fallback to Mshot
    171     if ( empty( $image ) ) {
    172         if ( is_singular() )
    173             $image = 'http://s.wordpress.com/mshots/v1/' . urlencode( get_permalink( $post->ID ) );
    174         else
    175             $image = 'http://s.wordpress.com/mshots/v1/' . urlencode( site_url() );
    176     }
     170    if ( empty( $image ) )
     171        $image = array();
     172    else if ( !is_array( $image ) )
     173        $image = array( $image );
     174
     175    // First fall back, mshots
     176    if ( is_singular() )
     177        $image[] = 'http://s.wordpress.com/mshots/v1/' . urlencode( get_permalink( $post->ID ) );
     178    else
     179        $image[] = 'http://s.wordpress.com/mshots/v1/' . urlencode( site_url() );
     180
     181    // Second fall back, blavatar
     182    if ( function_exists( 'blavatar_domain' ) ) {
     183        $blavatar_domain = blavatar_domain( site_url() );
     184        if ( blavatar_exists( $blavatar_domain ) )
     185            $image[] = blavatar_url( $blavatar_domain, 'img', $width );
     186    }
     187
     188    // Third fall back, gravatar
     189    if ( is_singular() && !is_home() && !is_front_page() && !empty( $post->post_author ) ) {
     190        $image[] = jetpack_og_get_image_gravatar( get_user_by( 'id', $post->post_author )->user_email, $width );
     191    }
     192
     193    // Fourth fall back, blank image
     194    $image[] = "http://wordpress.com/i/blank.jpg";
    177195
    178196    return $image;
    179197}
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
Note: See TracChangeset for help on using the changeset viewer.