Plugin Directory

Changeset 1631576


Ignore:
Timestamp:
04/06/2017 11:18:31 PM (9 years ago)
Author:
rodrigo73
Message:

Include support to wp_get_attachment_url for external thumbnail

Location:
rb-external-thumbnail/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rb-external-thumbnail/trunk/rb-external-thumbnail.php

    r1511791 r1631576  
    55 * Description: External images for post thumbnail.
    66 * Author: Rodrigo Brito
    7  * Version: 1.2
     7 * Version: 1.3
    88 * Author URI: http://www.rodrigobrito.net/
    99 * Text Domain: rb-external-thumbnail
     
    9494    return $metadata;
    9595}
     96
     97
     98add_filter( 'get_post_metadata', 'rb_external_inject_thumbnail_id', 10, 4 );
     99
     100function rb_external_inject_thumbnail_id ( $value, $post_id, $meta_key, $single ) {
     101    if ( $meta_key === '_thumbnail_id' ) {
     102        $url_thumbnail_external = get_post_meta( $post_id ,'thumbnail_external', true );
     103        if( !empty($url_thumbnail_external) ){
     104            return "ext-" . $post_id;
     105        }
     106    }
     107    return $value;
     108}
     109
     110add_filter( 'wp_get_attachment_image_src', 'rb_external_attachment_image_src', 10, 4 );
     111
     112function rb_external_attachment_image_src( $image, $attachment_id, $size, $icon ){
     113    if(isset($attachment_id) && !empty($attachment_id) && substr($attachment_id, 0, 3) === "ext"){
     114        $id = substr($attachment_id, 4);
     115        $thumbnail = get_post_meta( $id ,'thumbnail_external', true );
     116        return Array ( $thumbnail, 0, 0, false );
     117    }
     118    return $image;
     119}
  • rb-external-thumbnail/trunk/readme.txt

    r1511791 r1631576  
    33Tags: thumbnail, custom, external
    44Requires at least: 3.0.1
    5 Tested up to: 4.6.1
    6 Stable tag: 1.2
     5Tested up to: 4.7.3
     6Stable tag: 1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333= 1.2 =
    3434* Translation for other languagess
     35
     36= 1.3 =
     37* Support for external thumbnail called by wp_get_attachment_url
Note: See TracChangeset for help on using the changeset viewer.