示例#1
0
function hmp_gallery_meta_box($post)
{
    $image_ids = hmp_get_gallery_ids($post);
    //Prepend the _thumbnail_id to the array of gallery images if the gallery is set to manage the thumbnail
    if (get_option('hmp_manage_featured', true)) {
        $featured = array(0 => get_post_meta($post->ID, '_thumbnail_id', true));
        $image_ids = array_merge($featured, $image_ids);
    }
    global $temp_ID;
    $post_image_id = $post->ID ? $post->ID : $temp_ID;
    hm_register_custom_media_button('hmp_gallery_images', 'Add to Gallery', true, true, 150, 150);
    $non_added_text = "No Gallery Images Added " . (($hmp_url = hmp_get_url($post)) ? '| <a href="' . esc_url($hmp_url) . '" target="_blank">Screenshot your site now</a>' : '');
    hm_add_image_html_custom('hmp_gallery_images', 'Add Gallery Images', $post_image_id, $image_ids, 'sortable', 'width=150&height=150&crop=1', $non_added_text);
}
function jhp_get_gallery_ids($post = null)
{
    _deprecated_function(__FUNCTION__, '0.9.8', 'hmp_get_gallery_ids()');
    return hmp_get_gallery_ids($post);
}
示例#3
0
/**
*
*	Return an array of <img> for gallery. 
*	Does not return main image. 
*
*/
function hmp_get_the_gallery_images($post_id = null, $width_or_size = 'full', $h = 0, $crop = false)
{
    if ($post_id === null) {
        $post_id = get_the_ID();
    }
    if (!is_numeric($post_id)) {
        $post_id = $post_id->ID;
    }
    $images = array();
    $attachment_ids = hmp_get_gallery_ids($post_id);
    if (!$attachment_ids) {
        return array();
    }
    if (is_numeric($width_or_size)) {
        $crop = $crop ? '1' : '0';
        foreach ($attachment_ids as $id) {
            $images[$id] = wp_get_attachment_image($id, "width={$width_or_size}&height={$h}&crop={$crop}");
        }
    } else {
        foreach ($attachment_ids as $id) {
            $images[$id] = wp_get_attachment_image($id, $width_or_size);
        }
    }
    return $images;
}