Migrate Thesis Images to Genesis

If you’re moving from Thesis to Genesis, you might find that all your posts using Thesis’ Post Image are no longer displaying their image. Thesis stores its images in a custom field only they use.

Genesis fill first check for the Featured Image (a WordPress core feature), and if that’s not provided it will see which image was uploaded first to the post.

This code modifies that behavior. It first looks for the Featured Image, and if that is not provided it looks in the custom field Thesis uses. All your old Thesis images will show up in posts, and as you create new posts you can use the Featured Image option in WordPress.

<?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 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk