• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_attachment_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_get_attachment_link函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_attachment_link函数的具体用法?PHP wp_get_attachment_link怎么用?PHP wp_get_attachment_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_get_attachment_link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: jQuery_gallery

function jQuery_gallery($null, $attr)
{
    global $post;
    $attachments = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
    $lis = array();
    foreach ($attachments as $key => $attachment) {
        array_push($lis, '<li>' . wp_get_attachment_link($key, 'thumbnail', false, false) . '</li>');
    }
    $output = '
	<div id="gallery" class="ad-gallery">
		<div class="ad-image-wrapper"></div>
		<div class="ad-controls"></div>
		<div class="ad-nav">
			<div class="ad-thumbs">
				<ul class="ad-thumb-list">
					' . implode('', $lis) . '
				</ul>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	$("div.ad-gallery").adGallery({
		loader_image: "/i/loader.gif",
		slideshow:{enable:false},
		callbacks: {
			init: function() {
				this.preloadAll();
			}
		}
	});
	</script>
	';
    return $output;
}
开发者ID:adambrill,项目名称:Lake-Tomahawk-Bible-Church,代码行数:34,代码来源:jquery-gallery.php


示例2: vanilla_gallery

/**
 * OVERRIDES: gallery_shortcode()
 *
 * This implements the functionality of the Gallery Shortcode for displaying
 * WordPress images on a post.
 */
function vanilla_gallery($attr)
{
    global $post, $tpl;
    // BUG: I'm doing something wrong, because $attr is not the array of attributes from gallery_shortcode function. Why not??
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $id => $attachment) {
            $output .= wp_get_attachment_link($id, $size, true) . "\n";
        }
        return $output;
    }
    $images = array();
    foreach ($attachments as $id => $attachment) {
        $images[] = array("link" => wp_get_attachment_link($id, $size, true), "caption" => $captiontag && trim($attachment->post_excerpt) ? $attachment->post_excerpt : 0);
    }
    // Prepare the template data
    $tpl["gallery"] = array("tpl_file" => "shortcodes/gallery.html", "itemtag" => tag_escape($itemtag), "icontag" => tag_escape($icontag), "captiontag" => tag_escape($captiontag), "columns" => intval($columns), "itemwidth" => $columns > 0 ? floor(100 / $columns) - 1 : 100, "images" => $images);
    // Execute the template
    return vanilla_shortcode("gallery");
}
开发者ID:alicam,项目名称:vanilla-theme,代码行数:39,代码来源:gallery.php


示例3: wpa_slideshow_from_gallery

function wpa_slideshow_from_gallery($output, $attr)
{
    if (isset($attr['wpa_slideshow'])) {
        global $post, $wp_locale;
        static $instance = 0;
        $instance++;
        $size = isset($attr['size']) ? $attr['size'] : 'thumbnail';
        $attachments = explode(',', $attr['ids']);
        $output = apply_filters('gallery_style', "");
        $i = 0;
        $output .= '<div id="wpa-slideshow-' . $instance . '" class="wpa_slideshow swiper-container"><div class="swiper-wrapper">';
        foreach ($attachments as $id) {
            if (isset($attr['link']) && 'none' === $attr['link']) {
                $link = '<img src="' . image_src($id, $size) . '" alt="' . get_alt($id) . '" />';
            } elseif (isset($attr['link']) && 'file' === $attr['link']) {
                $link = wp_get_attachment_link($id, $size, false, false);
                $pic_link = str_replace('href="', 'target="_blank" href="', $link);
            } else {
                $link = wp_get_attachment_link($id, $size, true, false);
                $pic_link = str_replace('href="', 'target="_blank" href="', $link);
            }
            $pic_link = str_replace(wp_get_attachment_image_src($id, 'full', false), wp_get_attachment_image_src($id, 'large', false), $link);
            $pic_link = str_replace('src="', 'class="swiper-lazy" data-src="', $pic_link);
            $output .= '<div class="swiper-slide">';
            $output .= $pic_link;
            $output .= '<div class="swiper-lazy-preloader"></div></div>';
        }
        $output .= '</div><div class="swiper-pagination"></div><div class="swiper-button-prev"></div><div class="swiper-button-next"></div></div>';
    }
    return $output;
}
开发者ID:Tusko,项目名称:WP-Anatomy,代码行数:31,代码来源:admin-addons.php


示例4: suffusion_attachment

/**
 * Fetches the attachment for a post. This delegates the call to the handler for the appropriate attachment type.
 * The theme has inbuilt functions for image, audio, application, text and video. You can add your own handlers for other types
 * by creating a function called suffusion_your_type_attachment, where replace your_type with the new mime type.
 * Replace all occurrences of "." and "-" by "_". E.g. vnd-ms-powerpoint will give you suffusion_vnd_ms_powerpoint_attachment.
 *
 * @param bool $echo
 * @return mixed|string|void
 */
function suffusion_attachment($echo = true)
{
    $file = wp_get_attachment_url();
    $mime = get_post_mime_type();
    $mime_type = explode('/', $mime);
    // Reverse the array so that in mime type audio/mpeg, a call to the function for mpeg gets precedence over audio
    $mime_type = array_reverse($mime_type);
    $attachment = wp_get_attachment_link(0, 'full');
    foreach ($mime_type as $type) {
        $type = str_replace(array('.', '-'), '_', $type);
        if (function_exists("suffusion_{$type}_attachment")) {
            $attachment = call_user_func("suffusion_{$type}_attachment", $attachment, $mime, $file);
            $attachment = apply_filters('suffusion_attachment_html', $attachment);
            if ($echo) {
                echo $attachment;
            }
            return $attachment;
        }
    }
    $mime_type_class = suffusion_get_mime_type_class();
    $attachment = "<div class='{$mime_type_class}'>{$attachment}</div>";
    if ($echo) {
        echo $attachment;
    }
    return $attachment;
}
开发者ID:kevinaxu,项目名称:99boulders,代码行数:35,代码来源:media.php


示例5: cleanGallery

 public function cleanGallery($output, $attr)
 {
     static $cleaner_gallery_instance = 0;
     $cleaner_gallery_instance++;
     if (is_feed()) {
         return $output;
     }
     /* Default gallery settings. */
     $defaults = array('order' => 'ASC', 'orderby' => 'ID', 'id' => get_the_ID(), 'link' => '', 'itemtag' => 'figure', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => '', 'numberposts' => -1, 'offset' => '');
     $attr = array_merge($defaults, $attr);
     extract($attr);
     $id = intval($id);
     /* Arguments for get_children(). */
     $children = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $numberposts, 'offset' => $offset, 'suppress_filters' => true);
     if (empty($include)) {
         $attachments = get_children(array_merge(array('post_parent' => $id), $children));
     } else {
         $attachments = get_posts($children);
     }
     $attr['link'] = get_option('yopress_gallery_clean_link');
     if ($attr['link'] == '' || $attr['link'] == null) {
         $attr['link'] = 'big-thumbnail';
         update_option('yopress_gallery_clean_link', 'full');
     }
     $size = get_option('yopress_theme_gallery_def_size');
     if ($size == '' || $size == null) {
         $size = 'thumbnail';
         update_option('yopress_gallery_clean_size', 'thumbnail');
     }
     if (empty($attachments)) {
         return '<!-- No images. -->';
     }
     $itemtag = tag_escape($itemtag);
     $icontag = tag_escape($icontag);
     $captiontag = tag_escape($captiontag);
     $columns = intval($columns);
     $i = 0;
     $galleryWidth = floor(100 / $columns);
     $style = '<style type="text/css">#gallery-' . $cleaner_gallery_instance . ' .gallery-item			{ width : ' . $galleryWidth . '%}</style>';
     $output = $style;
     $output .= '<div id="gallery-' . $cleaner_gallery_instance . '" class="gallery gallery-columns-' . $columns . ' gallery-size-thumbnail">';
     $itemInColum = 0;
     foreach ($attachments as $attachment) {
         $output .= '<dl class="gallery-item"><dt class="gallery-icon">';
         $image = isset($attr['link']) && 'full' == $attr['link'] ? wp_get_attachment_link($attachment->ID, $size, false, false) : wp_get_attachment_link($attachment->ID, $size, true, false);
         $lightbox = $attr['link'] == 'full' ? 'class="apply-lightbox"' : '';
         $output .= "<div " . $lightbox . ">";
         $output .= apply_filters('cleaner_gallery_image', $image, $attachment->ID, $attr, $cleaner_gallery_instance);
         $output .= '</div>';
         $output .= '</dt></dl>';
         $itemInColum++;
         if ($itemInColum == $columns) {
             $itemInColum = 0;
             $output .= '<br class="clearfix">';
         }
     }
     $output .= '<br class="clearfix">';
     $output .= "</div><!-- .gallery -->";
     return $output;
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:60,代码来源:YoPressGalleryClean.php


示例6: _render

 protected function _render($args, $data)
 {
     if (empty($data['file'])) {
         return;
     }
     echo __('Download:', 'wpk15') . wp_get_attachment_link($data['file']);
 }
开发者ID:shtrihstr,项目名称:wpk15-theme-wpkit,代码行数:7,代码来源:PriceListWidget.php


示例7: sui_get_user_images_table

function sui_get_user_images_table($user_id)
{
    $args = array('author' => $user_id, 'post_type' => 'user_images', 'post_status' => 'pending');
    $user_images = new WP_Query($args);
    if (!$user_images->post_count) {
        return 0;
    }
    $out = '';
    $out .= '<p>Your unpublished images - Click to see full size</p>';
    $out .= '<form method="post" action="">';
    $out .= wp_nonce_field('sui_form_delete', 'sui_form_delete_submitted');
    $out .= '<table id="user_images">';
    $out .= '<thead><th>Image</th><th>Caption</th><th>Category</th><th>Delete</th></thead>';
    foreach ($user_images->posts as $user_image) {
        $user_image_cats = get_the_terms($user_image->ID, 'sui_image_category');
        foreach ($user_image_cats as $cat) {
            $user_image_cat = $cat->name;
        }
        $post_thumbnail_id = get_post_thumbnail_id($user_image->ID);
        $out .= wp_nonce_field('sui_image_delete_' . $user_image->ID, 'sui_image_delete_id_' . $user_image->ID, false);
        $out .= '<tr>';
        $out .= '<td>' . wp_get_attachment_link($post_thumbnail_id, 'thumbnail') . '</td>';
        $out .= '<td>' . $user_image->post_title . '</td>';
        $out .= '<td>' . $user_image_cat . '</td>';
        $out .= '<td><input type="checkbox" name="sui_image_delete_id[]" value="' . $user_image->ID . '" /></td>';
        $out .= '</tr>';
    }
    $out .= '</table>';
    $out .= '<input type="submit" name="sui_delete" value="Delete Selected Images" />';
    $out .= '</form>';
    return $out;
}
开发者ID:iwan14102065,项目名称:yes_wptheme,代码行数:32,代码来源:avatar-func.php


示例8: photoline_modified_post_gallery

function photoline_modified_post_gallery($output, $attr)
{
    global $post;
    static $instance = 0;
    $instance++;
    //disable all filter
    if (empty($attr['type']) || $attr['type'] != 'slider') {
        return;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'size' => 'photoline-featured', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $include = preg_replace('/[^0-9,]+/', '', $include);
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $selector = "gallery-{$instance}";
    $size_class = sanitize_html_class($size);
    $gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-size-{$size_class} flexslider'>";
    $output = apply_filters('gallery_style', $gallery_div);
    $output .= '<ul class="slides">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $caption = !empty($attachment->post_excerpt) ? '<p class="flex-caption wp-caption-text gallery-caption">' . wptexturize($attachment->post_excerpt) . '</p>' : '';
        $image = wp_get_attachment_image($id, $size);
        $output .= '<li>';
        $output .= $image;
        $output .= $caption;
        $output .= '</li>';
    }
    $output .= "\r\n            </ul><!-- .slides -->\r\n        </div>\n";
    return $output;
}
开发者ID:AlexanderDolgan,项目名称:ojahuri,代码行数:60,代码来源:gallery-layout.php


示例9: html

        /**
         * Get field HTML
         *
         * @param string $html
         * @param mixed  $meta
         * @param array  $field
         *
         * @return string
         */
        static function html($html, $meta, $field)
        {
            $i18n_delete = _x('Delete', 'file upload', 'rwmb');
            $i18n_title = _x('Upload files', 'file upload', 'rwmb');
            $i18n_more = _x('+ Add new file', 'file upload', 'rwmb');
            $delete_nonce = wp_create_nonce("rwmb-delete-file_{$field['id']}");
            // Uploaded files
            if (!empty($meta)) {
                $ol = '<ol class="rwmb-uploaded" data-field_id="%s" data-delete_nonce="%s" data-force_delete="%s">';
                $html .= sprintf($ol, $field['id'], $delete_nonce, $field['force_delete'] ? 1 : 0);
                $li = '<li>%s (<a title="%s" class="rwmb-delete-file" href="#" data-attachment_id="%s">%s</a>)</li>';
                foreach ($meta as $attachment_id) {
                    $attachment = wp_get_attachment_link($attachment_id);
                    $html .= sprintf($li, $attachment, $i18n_delete, $attachment_id, $i18n_delete);
                }
                $html .= '</ol>';
            }
            // Show form upload
            $html .= sprintf('<h4>%s</h4>
				<div class="new-files">
					<div class="file-input"><input type="file" name="%s[]" /></div>
					<a class="rwmb-add-file" href="#"><strong>%s</strong></a>
				</div>', $i18n_title, $field['id'], $i18n_more);
            return $html;
        }
开发者ID:cybKIRA,项目名称:roverlink-updated,代码行数:34,代码来源:file.php


示例10: custom_gallery

function custom_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    # hard-coding these values so that they can't be broken
    $attr['columns'] = 1;
    $attr['size'] = 'full';
    $attr['link'] = 'none';
    $attr['orderby'] = 'post__in';
    $attr['include'] = $attr['ids'];
    #Allow plugins/themes to override the default gallery template.
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    # We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'div', 'icontag' => 'div', 'captiontag' => 'p', 'columns' => 4, 'size' => 'gallery-thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = "<!-- see gallery_shortcode() in functions.php -->";
    }
    $gallery_div = "<ul class='clearing-thumbs small-block-grid-2 large-block-grid-4' data-clearing>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    foreach ($attachments as $id => $attachment) {
        $link = wp_get_attachment_link($id, 'full', false, false);
        $output .= "<li>";
        $output .= "{$link}";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<p class='wp-caption-text homepage-gallery-caption hide'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</p>";
        }
        $output .= "</li>";
    }
    $output .= "</ul>\n";
    return $output;
}
开发者ID:juan88ac,项目名称:foundation_s,代码行数:60,代码来源:custom-gallery-markup.php


示例11: html

        /**
         * Get field HTML
         *
         * @param string $html
         * @param mixed  $meta
         * @param array  $field
         *
         * @return string
         */
        static function html($html, $meta, $field)
        {
            $i18n_delete = _x('Delete', 'file upload', 'bootstrap');
            $i18n_title = _x('Upload files', 'file upload', 'bootstrap');
            $i18n_more = _x('+ Add new file', 'file upload', 'bootstrap');
            $html = wp_nonce_field("rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false);
            $html .= "<input type='hidden' class='field-id' value='{$field['id']}' />";
            // Uploaded files
            if (!empty($meta)) {
                $html .= '<ol class="rwmb-uploaded">';
                $li = '<li>%s (<a title="%s" class="rwmb-delete-file" href="#" rel="%s">%s</a>)</li>';
                foreach ($meta as $attachment_id) {
                    $attachment = wp_get_attachment_link($attachment_id);
                    $html .= sprintf($li, $attachment, $i18n_delete, $attachment_id, $i18n_delete);
                }
                $html .= '</ol>';
            }
            // Show form upload
            $html .= sprintf('<h4>%s</h4>
				<div class="new-files">
					<div class="file-input"><input type="file" name="%s[]" /></div>
					<a class="rwmb-add-file" href="#"><strong>%s</strong></a>
				</div>', $i18n_title, $field['id'], $i18n_more);
            return $html;
        }
开发者ID:scotlanddig,项目名称:bootstrap_basic,代码行数:34,代码来源:file.php


示例12: roots_gallery

/**
 * Clean up gallery_shortcode()
 *
 * Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap
 *
 * @link http://twitter.github.com/bootstrap/components.html#thumbnails
 */
function roots_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    if (!empty($attr['ids'])) {
        if (empty($attr['orderby'])) {
            $attr['orderby'] = 'post__in';
        }
        $attr['include'] = $attr['ids'];
    }
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => '', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => 'file'), $attr));
    $id = intval($id);
    if ($order === 'RAND') {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $output = '<ul class="thumbnails gallery">';
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $image = 'file' == $link ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= '<li>' . $image;
        if (trim($attachment->post_excerpt)) {
            $output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>';
        }
        $output .= '</li>';
    }
    $output .= '</ul>';
    return $output;
}
开发者ID:NaszvadiG,项目名称:roots,代码行数:67,代码来源:gallery.php


示例13: gallery_shortcode

 function gallery_shortcode($output, $attr)
 {
     global $post;
     if (!isset($attr['royalslider'])) {
         if (NewRoyalSliderMain::$override_all_default_galleries) {
             $rsid = NewRoyalSliderMain::$override_all_default_galleries;
         } else {
             return $output;
         }
     } else {
         $rsid = $attr['royalslider'];
     }
     // $rsdata = NewRoyalSliderMain::query_slider_data( $rsid );
     // if(!$rsdata || !$rsdata[0]) {
     // 	return NewRoyalSliderMain::frontend_error(__('Incorrect royalslider ID in gallery shortcode (or in Global, or problem with query.', 'new_royalslider'));
     // }
     // $rsdata = $rsdata[0];
     if (isset($attr['orderby'])) {
         $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
         if (!$attr['orderby']) {
             unset($attr['orderby']);
         }
     }
     extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => ''), $attr));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($ids)) {
         // 'ids' is explicitly ordered
         $orderby = 'post__in';
         $include = $ids;
     }
     if (!empty($include)) {
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     if (empty($attachments)) {
         return NewRoyalSliderMain::frontend_error(__('No post attachments found.', 'new_royalslider'));
     }
     if (is_feed()) {
         $output = "\n";
         foreach ($attachments as $att_id => $attachment) {
             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
         }
         return $output;
     }
     require_once 'rsgenerator/NewRoyalSliderGenerator.php';
     return NewRoyalSliderGenerator::generateSlides(true, true, $rsid, 'gallery', null, $attachments, null, null, null, true);
     return $output;
 }
开发者ID:treydonovan,项目名称:mymexicotours,代码行数:58,代码来源:GalleryShortcode.php


示例14: custom_gallery

function custom_gallery($attr)
{
    $post = get_post();
    static $instance = 0;
    $instance++;
    $attr['columns'] = 1;
    $attr['size'] = 'full';
    $attr['link'] = 'none';
    $attr['orderby'] = 'post__in';
    $attr['include'] = $attr['ids'];
    $output = apply_filters('post_gallery', '', $attr);
    if ($output != '') {
        return $output;
    }
    # We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'div', 'icontag' => 'div', 'captiontag' => 'p', 'columns' => 1, 'size' => 'thumbnail', 'include' => '', 'exclude' => ''), $attr));
    $id = intval($id);
    if ('RAND' == $order) {
        $orderby = 'none';
    }
    if (!empty($include)) {
        $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($exclude)) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    }
    if (empty($attachments)) {
        return '';
    }
    $gallery_style = $gallery_div = '';
    if (apply_filters('use_default_gallery_style', true)) {
        $gallery_style = "<!-- see gallery_shortcode() in functions.php -->";
    }
    $gallery_div = "<div class='gallery gallery-columns-1 gallery-size-full'>";
    $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
    foreach ($attachments as $id => $attachment) {
        $link = wp_get_attachment_link($id, 'thumbnail', false, false);
        $output .= "\n\t\t\t\n                         <div class='imgc'>\n\t\t\t\t{$link} \n\t\t\t</div>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<p class='wp-caption-text homepage-gallery-caption'>\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\n\t\t\t\t</p>";
        }
        $output .= "";
    }
    $output .= "</div>\n";
    return $output;
}
开发者ID:n0x5,项目名称:code-2-wp-theme,代码行数:57,代码来源:plugin-functions.php


示例15: vw_custom_post_gallery

 function vw_custom_post_gallery($null, $attr = array())
 {
     global $post, $wp_locale;
     static $instance = 0;
     $instance++;
     extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'figure', 'captiontag' => 'figcaption', 'columns' => 3, 'size' => 'vw_medium', 'include' => '', 'exclude' => ''), $attr));
     $id = intval($id);
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($include)) {
         $include = preg_replace('/[^0-9,]+/', '', $include);
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     if (empty($attachments)) {
         return '';
     }
     if (is_feed()) {
         $output = "\n";
         foreach ($attachments as $att_id => $attachment) {
             $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
         }
         return $output;
     }
     $itemtag = tag_escape($itemtag);
     $captiontag = tag_escape($captiontag);
     $float = is_rtl() ? 'right' : 'left';
     $gallery_layout = vw_get_option('blog_custom_gallery_layout', '213');
     $output = "<div id='gallery-{$instance}' class='custom-gallery galleryid-{$id} clearfix' data-gallery-layout='{$gallery_layout}'>";
     if ($itemtag != '' && $captiontag != '') {
         $i = 1;
         foreach ($attachments as $id => $attachment) {
             $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, false, false);
             $link = str_replace('<a', '<a title="' . $attachment->post_excerpt . '" ', $link);
             $output .= "<{$itemtag} class='gallery-item'>";
             $output .= "{$link}";
             if ($captiontag && trim($attachment->post_excerpt)) {
                 $output .= "\r\n\t\t\t\t\t<{$captiontag} class='gallery-caption'>\r\n\t\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t\t</{$captiontag}>";
             }
             $output .= "</{$itemtag}>";
             $i++;
         }
     }
     $output .= "</div>\n";
     return $output;
 }
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:55,代码来源:gallery.php


示例16: pressplay_gallery_shortcode

function pressplay_gallery_shortcode($null, $attr = array())
{
    global $post;
    static $instance = 0;
    $instance++;
    // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
    if (isset($attr['orderby'])) {
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
        if (!$attr['orderby']) {
            unset($attr['orderby']);
        }
    }
    extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail'), $attr));
    $id = intval($id);
    $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
        }
        return $output;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    if ($columns >= 4) {
        $galleryItemDimensions = "height:80%;width:80%;";
    } else {
        $galleryItemDimensions = "";
    }
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $itemheight = $itemwidth;
    $selector = "gallery-{$instance}";
    $output = apply_filters('gallery_style', "\r\n\t\t<style type='text/css'>\r\n\t\t\t#{$selector} {\r\n\t\t\t\tmargin: auto;\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-item {\r\n\t\t\t\tfloat: left;\r\n\t\t\t\tmargin-top: 10px;\r\n\t\t\t\ttext-align: center;\r\n\t\t\t\twidth: {$itemwidth}%;\r\n\t\t\t\theight: {$itemheight}%;\r\n\t\t\t}\r\n\t\t\t#{$selector} img {\r\n\t\t\t\tborder: 2px solid #cfcfcf;\r\n\t\t\t\t" . $galleryItemDimensions . "\t\t\t\r\n\t\t\t}\r\n\t\t\t#{$selector} .gallery-caption {\r\n\t\t\t\tmargin-left: 0;\r\n\t\t\t}\r\n\t\t</style>\r\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\r\n\t\t<div id='{$selector}' class='gallery galleryid-{$id}'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\r\n\t\t\t<{$icontag} class='gallery-icon'>\r\n\t\t\t\t{$link}\r\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\r\n\t\t\t\t<{$captiontag} class='gallery-caption'>\r\n\t\t\t\t" . wptexturize($attachment->post_excerpt) . "\r\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\r\n\t\t\t<br style='clear: both;' />\r\n\t\t</div>\n";
    return $output;
}
开发者ID:rraval,项目名称:PressPlay,代码行数:53,代码来源:gallery-mod.php


示例17: get_attachment_link

 public function get_attachment_link()
 {
     if (isset($this->image_exist()['noexists']) || empty($this->attachment) || 'attachment' != $this->attachment->post_type || !wp_get_attachment_url($this->attachment->ID)) {
         if (!empty($this->img_src_ext)) {
             return $this->filter_attachment_link();
         }
         return wp_get_attachment_image($this->attachment_id, $this->size, $this->icon, $this->attr);
     }
     add_filter('wp_get_attachment_link', array($this, 'filter_attachment_link'), 20, 6);
     $this->attach_link = wp_get_attachment_link($this->attachment_id, $this->size, $this->permalink, $this->icon, $this->text, $this->attr);
     return $this->attach_link;
 }
开发者ID:Jevuska,项目名称:extended-related-posts,代码行数:12,代码来源:class-extrp-thumbnail.php


示例18: slick_shortcode

function slick_shortcode($attr)
{
    $post = get_post();
    //Create list of parameters, with defaults.
    $atts = shortcode_atts(array('id' => $post ? $post->ID : 0, 'size' => 'large', 'link' => '', 'ids' => ''), $attr, 'gallery');
    $id = intval($atts['id']);
    /* retrieve properly sized images */
    //If the ids field is filled, use the ids there to populate the gallery
    if (!empty($atts['ids'])) {
        $_attachments = get_posts(array('include' => $atts['ids'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
        //otherwise, retrieve all children of the current post
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
    }
    //If those steps failed, return nothing now
    if (empty($attachments)) {
        return '';
    }
    //If we are in a feed, return unstyled list of images
    if (is_feed()) {
    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_attachment_metadata函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_attachment_image_url函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap