本文整理汇总了PHP中wp_get_attachment_link函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_attachment_link函数的具体用法?PHP wp_get_attachment_link怎么用?PHP wp_get_attachment_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_attachment_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}
示例6: _render
protected function _render($args, $data)
{
if (empty($data['file'])) {
return;
}
echo __('Download:', 'wpk15') . wp_get_attachment_link($data['file']);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}