Convert featured images into “product images”

That sounds weird because post thumbnails were changed to Featured Images with WP 3.0. I guess you’re talking about some custom field or metabox your framework adds on post edit. You could grab _thumbnail_id which is the key in the wp_postmeta table that stores what you’re looking for. But to me you’d better usewp_get_attachment_img_src: if(has_post_thumbnail($post->ID)) … Read more

Custom field image to Featured Image

I put this together for you as a proof-of-concept. This class will migrate both attachment IDs and external image URLs into your featured images. class Featured_Image_Migration{ #Instantiate the migration by hitting /wp-admin/?migrate-post-meta=foobar protected $key = ‘migrate-post-meta’; protected $secret=”foobar”; #This is your legacy meta_key protected $meta_key = ‘mainimg_medium’; function __construct(){ #Force this to run last so … Read more

How To Use YouTube Url Stored In Custom Field To Get Video Image and Set it As Featured Image

function set_youtube_as_featured_image($post_id) { if( has_post_thumbnail($post_id) ) return; $url = get_post_meta($post_id, ‘ci_cpt_video_link’, true); if ( $url && filter_var($url, FILTER_VALIDATE_URL) ) { // getting thumb url from video url parse_str( parse_url( $url, PHP_URL_QUERY ), $youtube_vars ); $youtube_id = $youtube_vars[‘v’]; $youtube_thumb_url=”http://img.youtube.com/vi/” . $youtube_id . ‘/0.jpg’; // download and save thumb $get = wp_remote_get( $youtube_thumb_url ); $mime_type = wp_remote_retrieve_header( … Read more

How to add icon over specific thumb

The implementation can be purely CSS, and depends on your specific HTML markup. However, the class you’ll need to target is supplied by the post_class() template tag. Let’s say you have something like the following, basic markup: <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <div class=”post-title”> <img … /> <h1><?php the_title(); ?></h1> </div> <!– Etc. … Read more

Change custom featured image size in twentythirteen child theme

The function that handles thumbnail size is already hooked with after_setup_theme in \twentythirteen\functions.php. There is no use adding a if (!function_exists()) in child functions.php because the child functions.php is always loaded before. So this would be more logical to find this in the parent file. The answer would be to set a different prority to … Read more

How to get featured image thumbnail to open larger version in attachment page?

Use get_attachment_link to get a link to the attachment page or take a look at wp_get_attachment_link which might simplify the process. <?php if(has_post_thumbnail()) : ?> <div class=”spudpictureandcontentwrapper”> <div class=”illustration”><?php $attachment_id = get_post_thumbnail_id(); $large_image_url = wp_get_attachment_image_src($attachment_id, ‘large’); $attachment_page = get_attachment_link($attachment_id); echo ‘<a href=”‘ . esc_url($attachment_page) . ‘” title=”‘ . esc_attr(get_the_title($attachment_id)) . ‘” >’; the_post_thumbnail(‘thumbnail’); ?> </a></div> … Read more