-
-
Save billerickson/bba3f2f8149f10e2eeb3 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Thesis to Genesis Image | |
* Uses Thesis' post image as backup for genesis_get_image() | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/migrate-thesis-images-genesis/ | |
*/ | |
function be_thesis_to_genesis_image( $output, $args, $id, $html, $url, $src ) { | |
if( has_post_thumbnail() ) | |
return $output; | |
$image_key = 'thumbnail' == $args['size'] ? 'thesis_thumb' : 'thesis_post_image'; | |
$alt_key = 'thumbnail' == $args['size'] ? 'thesis_thumb_alt' : 'thesis_post_image_alt'; | |
$url = esc_url( get_post_meta( get_the_ID(), $image_key, true ) ); | |
$alt = esc_attr( get_post_meta( get_the_ID(), $alt_key, true ) ); | |
if( empty( $url ) ) | |
return $output; | |
if( 'url' == $args['format'] ) | |
return $url; | |
else | |
return '<img src="' . $url . '" alt="' . $alt . '" class="alignleft post-image entry-image" itemprop="image" />'; | |
} | |
add_filter( 'genesis_get_image', 'be_thesis_to_genesis_image', 10, 6 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I cannot run it against thesis 2.1 and Genesis 2.2.3 with wordpress 4.3.1.
It is function for these versions or it is a script for an older version of thesis, like 1.8.* ?
Greetings from Hamburg,
Hans