Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 9, 2014 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/bba3f2f8149f10e2eeb3 to your computer and use it in GitHub Desktop.
Save billerickson/bba3f2f8149f10e2eeb3 to your computer and use it in GitHub Desktop.
<?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 );
@hansbraumueller
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment