Skip to content

Instantly share code, notes, and snippets.

@billerickson billerickson/functions.php Secret

Created Oct 9, 2014
Embed
What would you like to do?
<?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

This comment has been minimized.

Copy link

hansbraumueller commented Nov 3, 2015

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
You can’t perform that action at this time.