Last active
May 31, 2017 14:47
-
-
Save aliaghdam/8ef5f97413f92485968c187ce838fef5 to your computer and use it in GitHub Desktop.
"Publisher" compatibility with "Featured Image From URL"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_get_attachment_image_src', 'fifu_replace_attachment_image_src', 10, 2 ); | |
if ( ! function_exists( 'fifu_replace_attachment_image_src' ) ) { | |
/** | |
* Replaced attachment src with external thumbnail URL | |
* | |
* @hooked wp_get_attachment_image_src | |
* | |
* @param $image | |
* @param $attachment_id | |
* | |
* @return array | |
*/ | |
function fifu_replace_attachment_image_src( $image, $attachment_id ) { | |
if ( $attachment_id == get_post_thumbnail_id( get_the_ID() ) ) { | |
$src = get_post_meta( get_the_ID(), 'fifu_image_url', TRUE ); | |
if ( $src ) { | |
return array( | |
$src, | |
0, | |
0, | |
FALSE | |
); | |
} | |
} | |
return $image; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment