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;
}
Example #2
0
/**
 * 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");
}
Example #3
0
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;
}
Example #4
0
/**
 * 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;
}
 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;
 }
 protected function _render($args, $data)
 {
     if (empty($data['file'])) {
         return;
     }
     echo __('Download:', 'wpk15') . wp_get_attachment_link($data['file']);
 }
Example #7
0
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;
}
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;
}
Example #9
0
        /**
         * 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;
        }
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;
}
Example #11
0
        /**
         * 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;
        }
Example #12
0
/**
 * 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;
}
 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;
 }
Example #14
0
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;
}
 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;
 }
Example #16
0
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;
}
 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;
 }
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()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $atts['size'], true) . "\n";
        }
        return $output;
    }
    /* insert images into a template */
    //Initial boilerplate
    $output = '<div class="gallery-container">' . '<div class="arrows-container">' . '<div class="arrow-left">' . '<img src="' . get_template_directory_uri() . '/images/thin_left_arrow_333.png" />' . '</div>' . '<div class="arrow-right">' . '<img src="' . get_template_directory_uri() . '/images/thin_right_arrow_333.png" />' . '</div>' . '</div>' . '<div class="slicktarget gallery">';
    foreach ($attachments as $id => $attachment) {
        if (!empty($atts['link']) && $atts['link'] === 'file') {
            $image_output = wp_get_attachment_link($id, $atts['size'], false, false, false);
        } elseif (!empty($atts['link']) && $atts['link'] === 'none') {
            $image_output = wp_get_attachment_image($id, $atts['size'], false);
        } else {
            $image_output = wp_get_attachment_link($id, $atts['size'], true, false, false);
        }
        // If image has an excerpt make room for it
        if ($attachment->post_excerpt !== '') {
            $output .= '<div class="slick-item"><div class="imagearea">' . $image_output . '</div>';
            $output .= '<div class="textarea wp-caption"><span class="slick-counter"></span> — ' . $attachment->post_excerpt . '</div></div>';
            //If it doesn't don't
        } else {
            $output .= '<div class="slick-item">' . $image_output . '</div>';
        }
    }
    $output .= "</div></div>\n";
    return $output;
}
function default_item_callback($post_item, $size = 'medium')
{
    //echo "post_item<pre>"; print_r($post_item); echo "</pre>";
    if (wp_attachment_is_image($post_item->ID)) {
        $image_src = wp_get_attachment_image_src($post_item->ID, $size);
        /*
        		return '<li class="media-tag-list" id="media-tag-item-'.$post_item->ID.'"><img src="'.$image_src[0].'" width="'.$image_src[1].'" height="'.$image_src[2].'"
        				title="'.$post_item->post_title.'" /></li>';
        */
        return '<li class="media-tag-list" id="media-tag-item-' . $post_item->ID . '">' . wp_get_attachment_image($post_item->ID, $size) . '</li>';
    } else {
        return '<li class="media-tag-list" id="media-tag-item-' . $post_item->ID . '">' . wp_get_attachment_link($post_item->ID) . '</li>';
    }
}
Example #20
0
function theme_gallery_shortcode($attr)
{
    global $post;
    // 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' => '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;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = intval($columns);
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = '<div class="gallery">' . "\n";
    $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 .= "\n<" . $itemtag . ' class="gallery-item" style="width:' . $itemwidth . '%;">' . "\n";
        $output .= '<' . $icontag . ' class="gallery-icon">' . $link . '</' . $icontag . '>';
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= '<' . $captiontag . ' class="gallery-caption">' . $attachment->post_excerpt . '</' . $captiontag . '>';
        }
        $output .= '</' . $itemtag . '>' . "\n";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= "\n" . '<br class="clear" />' . "\n";
        }
    }
    $output .= "\n" . '<br class="clear" />' . "</div>\n";
    return $output;
}
Example #21
0
 /**
  * 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');
     $html = wp_nonce_field("rwmb-delete-file_{$field['id']}", "nonce-delete-file_{$field['id']}", false, false);
     if ($meta) {
         $html .= '<ol class="rwmb-uploaded">';
         $li = '<li>%s (<a title="%s" class="rwmb-delete-file" href="#" data-field_id="%s" data-attachment_id="%s">%s</a>)</li>';
         $attachment = wp_get_attachment_link($meta);
         $html .= sprintf($li, $attachment, $i18n_delete, $field['id'], $meta, $i18n_delete);
         $html .= '</ol>';
     }
     // Show form upload
     $html .= sprintf('<input type="file" name="%s" />', $field['field_name']);
     return $html;
 }
Example #22
0
function vanilla_adjacent_image_link($prev = true)
{
    global $post;
    $post = get_post($post);
    $attachments = array_values(get_children(array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID')));
    foreach ($attachments as $k => $attachment) {
        if ($attachment->ID == $post->ID) {
            break;
        }
    }
    $k = $prev ? $k - 1 : $k + 1;
    if (isset($attachments[$k])) {
        return wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
    }
}
Example #23
0
function cfct_post_gallery($attr)
{
    global $post;
    // 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;
    }
    $itemtag = tag_escape($itemtag);
    $captiontag = tag_escape($captiontag);
    $columns = apply_filters('cfct_post_gallery_columns', intval($columns));
    $itemwidth = $columns > 0 ? floor(100 / $columns) : 100;
    $output = apply_filters('gallery_style', "\n\t\t<style type='text/css'>\n\t\t\t.gallery {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t.gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: {$itemwidth}%;\t\t\t}\n\t\t\t.gallery img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t.gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t</style>\n\t\t<!-- see gallery_shortcode() in wp-includes/media.php -->\n\t\t<div class='gallery'>");
    $i = 0;
    foreach ($attachments as $id => $attachment) {
        // get full item src
        $item_src = wp_get_attachment_image_src($id, 'full', false);
        $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
        // add full item src as rel
        $link = str_replace('><img', ' class="thickbox" rel="' . $item_src[0] . '"><img', $link);
        $output .= "<{$itemtag} class='gallery-item'>";
        $output .= "\n\t\t\t<{$icontag} class='gallery-icon'>\n\t\t\t\t{$link}\n\t\t\t</{$icontag}>";
        if ($captiontag && trim($attachment->post_excerpt)) {
            $output .= "\n\t\t\t\t<{$captiontag} class='gallery-caption'>\n\t\t\t\t{$attachment->post_excerpt}\n\t\t\t\t</{$captiontag}>";
        }
        $output .= "</{$itemtag}>";
        if ($columns > 0 && ++$i % $columns == 0) {
            $output .= '<br style="clear: both" />';
        }
    }
    $output .= "\n\t\t\t<br style='clear: both;' />\n\t\t</div>\n";
    return $output;
}
Example #24
0
function natural_gallery_shortcode($output = '', $attr, $instance)
{
    // Use default gallery if infinite scroll is disabled
    if (!isset($attr['active']) || $attr['active'] != 'true') {
        return null;
    }
    naturalScripts();
    add_action('wp_footer', 'photoswipeTemplate');
    $post = get_post();
    $atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'columns' => 3, 'size' => 'medium', 'include' => '', 'exclude' => '', 'link' => ''), $attr, 'gallery');
    $id = intval($atts['id']);
    if (!empty($atts['include'])) {
        $_attachments = get_posts(array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
        $attachments = array();
        foreach ($_attachments as $key => $val) {
            $attachments[$val->ID] = $_attachments[$key];
        }
    } elseif (!empty($atts['exclude'])) {
        $attachments = get_children(array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
    } else {
        $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
    }
    if (empty($attachments)) {
        return '';
    }
    if (is_feed()) {
        $output = "\n";
        foreach ($attachments as $att_id => $attachment) {
            $output .= wp_get_attachment_link($att_id, $atts['size'], true) . "\n";
        }
        return $output;
    }
    $attr['thumbnailmaximumheight'] = 0;
    $items = [];
    foreach ($attachments as $id => $attachment) {
        $thumbHeight = wp_get_attachment_image_src($id, $atts['size'])[2];
        if ($thumbHeight > $attr['thumbnailmaximumheight']) {
            $attr['thumbnailmaximumheight'] = $thumbHeight;
        }
        $item = ['thumbnail' => wp_get_attachment_image_src($id, $atts['size'])[0], 'enlarged' => wp_get_attachment_image_src($id, 'full')[0], 'id' => $id, 'title' => $attachment->post_excerpt, 'thumbName' => $atts['size'], 'tWidth' => wp_get_attachment_image_src($id, $atts['size'])[1], 'tHeight' => wp_get_attachment_image_src($id, $atts['size'])[2], 'eWidth' => wp_get_attachment_image_src($id, 'full')[1], 'eHeight' => wp_get_attachment_image_src($id, 'full')[2]];
        $items[] = $item;
    }
    // variables used in templates
    $items = json_encode($items);
    $output = (require 'templates/gallery.php');
    return $output;
}
Example #25
0
function heidelicious_slide($atts, $content = null)
{
    global $post;
    if (is_home()) {
        return;
    }
    extract(shortcode_atts(array("id" => $post->ID, "orderby" => 'rand'), $atts));
    $attachments = get_posts(array('orderby' => $orderby, 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $id, 'exclude' => get_post_thumbnail_id()));
    if ($attachments) {
        $out = '<div class="slide">';
        foreach ($attachments as $attachment) {
            $out .= wp_get_attachment_link($attachment->ID, 'medium');
        }
        $out .= '</div>';
        return $out;
    }
}
function gallery_shortcode_tbs($attr)
{
    global $post, $wp_locale;
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID);
    $attachments = get_posts($args);
    if ($attachments) {
        $output = '<ul class="media-grid">';
        foreach ($attachments as $attachment) {
            $output .= '<li>';
            $att_title = apply_filters('the_title', $attachment->post_title);
            $output .= wp_get_attachment_link($attachment->ID, 'thumbnail', true);
            $output .= '</li>';
        }
        $output .= '</ul>';
    }
    return $output;
}
function ml_shortcode($atts)
{
    extract(shortcode_atts(array('id' => ''), $atts));
    if ($id == '') {
        return '';
    }
    // (error checking) return '' if blank
    $begin = '<ul class="attachment_list">';
    $parts = explode(',', $id);
    $list = '';
    foreach ($parts as $el) {
        // creates the list items
        $list = $list . '<li>' . wp_get_attachment_link($el) . '</li>';
    }
    $end = '</ul>';
    return $begin . $list . $end;
    // returns the full list
}
Example #28
0
 /**
  * filter output of plugin
  */
 public static function filter_output($default_output, $images, $post_settings, $post_id)
 {
     if ($post_settings["display_settings"] === 'bxslider' && in_array('bxslider', p2gallery::get_enabled_extensions())) {
         $out = '';
         if (count($images)) {
             if (is_feed()) {
                 $out .= "\n";
                 foreach ($images as $image) {
                     $out .= wp_get_attachment_link($image->ID, $post_settings["bx_imagesize"], true) . "\n";
                 }
             } else {
                 /* enqueue library script */
                 add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_script'));
                 $counter = 0;
                 /* add data attributes for settings */
                 $settingsAttr = array('slideinterval', 'firstslidedelay', 'navigation', 'hascaption', 'adaptiveheight', 'autostart');
                 $attr = '';
                 foreach ($settingsAttr as $setting) {
                     $attr .= sprintf(' data-%s="%s"', $setting, $post_settings['bx_' . $setting]);
                 }
                 $out .= sprintf('<div id="p2gallery_container"><div id="p2gallery_bx"%s>', $attr);
                 $captions = '';
                 foreach ($images as $image) {
                     $full = wp_get_attachment_image_src($image->ID, $post_settings["bx_imagesize"]);
                     $thumb = wp_get_attachment_image_src($image->ID, $post_settings["bx_thumbsize"]);
                     $meta = get_post_meta($image->ID, '_wp_attachment_image_alt', true);
                     $alt = trim($meta) !== '' ? trim($meta) : $image->post_title;
                     $out .= sprintf('<div data-captionid="caption_%s" class="slide" data-thumbsrc="%s" data-slideid="%d"><img src="%s" alt="%s" title="%s" data-slideid="%d">', $image->ID, esc_attr($thumb[0]), $counter, $full[0], esc_attr($alt), esc_attr($image->post_title), $counter);
                     if ($post_settings["bx_hascaption"]) {
                         $class = isset($post_settings["bx_captionclass"]) && trim($post_settings["bx_captionclass"]) !== '' ? " " . trim($post_settings["bx_captionclass"]) : '';
                         $captions .= sprintf('<div id="caption_%d" class="caption%s">%s</div>', $image->ID, $class, apply_filters('the_content', $image->post_excerpt));
                     }
                     $out .= '</div>';
                     $counter++;
                 }
                 $out .= '</div>' . $captions . '</div>';
             }
         }
         return $out;
     } else {
         return $default_output;
     }
 }
Example #29
0
 function upload_file($image_only = false)
 {
     $this->validate_nonce();
     // a valid request will have a form ID
     $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : false;
     if (!$form_id) {
         die('error');
     }
     // check if guest post enabled for guests
     if (!is_user_logged_in()) {
         $guest_post = false;
         $form_settings = wpuf_get_form_settings($form_id);
         if (isset($form_settings['guest_post']) && $form_settings['guest_post'] == 'true') {
             $guest_post = true;
         }
         if (!$guest_post) {
             die('error');
         }
     }
     $upload = array('name' => $_FILES['wpuf_file']['name'], 'type' => $_FILES['wpuf_file']['type'], 'tmp_name' => $_FILES['wpuf_file']['tmp_name'], 'error' => $_FILES['wpuf_file']['error'], 'size' => $_FILES['wpuf_file']['size']);
     header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     $attach = $this->handle_upload($upload);
     if ($attach['success']) {
         $response = array('success' => true);
         if ($image_only) {
             $image_size = wpuf_get_option('insert_photo_size', 'wpuf_general', 'thumbnail');
             $image_type = wpuf_get_option('insert_photo_type', 'wpuf_general', 'link');
             if ($image_type == 'link') {
                 $response['html'] = wp_get_attachment_link($attach['attach_id'], $image_size);
             } else {
                 $response['html'] = wp_get_attachment_image($attach['attach_id'], $image_size);
             }
         } else {
             $response['html'] = $this->attach_html($attach['attach_id']);
         }
         echo $response['html'];
     } else {
         echo 'error';
     }
     // $response = array('success' => false, 'message' => $attach['error']);
     // echo json_encode( $response );
     exit;
 }
 function upload_file($image_only = false)
 {
     $upload = array('name' => $_FILES['wpuf_file']['name'], 'type' => $_FILES['wpuf_file']['type'], 'tmp_name' => $_FILES['wpuf_file']['tmp_name'], 'error' => $_FILES['wpuf_file']['error'], 'size' => $_FILES['wpuf_file']['size']);
     header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     $attach = $this->handle_upload($upload);
     if ($attach['success']) {
         $response = array('success' => true);
         if ($image_only) {
             $image_size = wpuf_get_option('insert_photo_size', 'wpuf_general', 'thumbnail');
             $image_type = wpuf_get_option('insert_photo_type', 'wpuf_general', 'link');
             if ($image_type == 'link') {
                 $response['html'] = wp_get_attachment_link($attach['attach_id'], $image_size);
             } else {
                 $response['html'] = wp_get_attachment_image($attach['attach_id'], $image_size);
             }
         } else {
             $response['html'] = $this->attach_html($attach['attach_id']);
         }
         echo $response['html'];
     } else {
         echo 'error';
     }
     // $response = array('success' => false, 'message' => $attach['error']);
     // echo json_encode( $response );
     exit;
 }