Example #1
0
function ac_get_post_thumbnail_id($post)
{
    $post = get_post($post);
    $post_type = get_post_type($post);
    switch ($post_type) {
        case 'attachment':
            // Post ID is the attachment ID for images
            return $post->ID;
        case 'ac_gallery':
            return ac_gallery_get_cover_image_id_for_gallery($post);
        default:
            return get_post_thumbnail_id($post->ID);
    }
}
function ac_gallery_get_cover_image_for_gallery($gallery_id, $image_size)
{
    $image_id = ac_gallery_get_cover_image_id_for_gallery($gallery_id);
    if ($image_id) {
        // Return the first instance
        $img = wp_get_attachment_image_src($image_id, $image_size, false);
        $img = $img[0];
        return $img;
    }
    return false;
}