コード例 #1
0
/** Show Photo gallery shortcode
 * [photo-gallery]
 */
function guiabsn_shortcode_photo_gallery($atts)
{
    global $post;
    extract(shortcode_atts(array('size' => 'photography'), $atts));
    $_attachments = get_posts(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    // return false when invalid
    if (!count($_attachments)) {
        return false;
    }
    $output = '';
    $group_class = 'phogal-' . $post->ID;
    $output .= '<ul id="pg-thumb-list" class="pg-thumb-list">' . "\r\n";
    foreach ($_attachments as $key => $val) {
        $img_thumb = wp_get_attachment_image_src($val->ID, $size, false);
        $img_full_url = $val->guid;
        $output .= '<li id="thumb-' . $val->ID . '">';
        $output .= '<div class="pg-thumb-content">';
        $output .= '<a class="popup-img ' . $group_class . '" rel="' . $group_class . '" title="' . $val->post_title . '" href="' . get_attachment_link($val->ID) . '" data-url="' . $img_full_url . '"><img class="pt-thumb-image" src="' . $img_thumb[0] . '" alt="" title="" /></a>';
        $output .= '</div>';
        $output .= '</li>' . "\r\n";
    }
    $output .= '</ul>' . "\r\n";
    // fancybox
    if (count($_attachments)) {
        guiabsn_scripts_fancybox();
        $output .= '<script type="text/javascript">' . "\r\n" . '$(document).ready(function() {' . "\r\n" . '$("a[rel=\'' . $group_class . '\']").fancybox({ ' . "\r\n" . 'scrolling: "no", ' . "\r\n" . 'centerOnScroll: "true" ' . "\r\n" . '});' . "\r\n" . '});' . "\r\n" . '</script>' . "\r\n";
    }
    return $output;
}
コード例 #2
0
ファイル: custom-hooks.php プロジェクト: nevertry/guiabsn
function guiabsn_enqueue_style()
{
    guiabsn_scripts_fancybox();
}