本文整理汇总了PHP中msp_get_the_resized_image_src函数的典型用法代码示例。如果您正苦于以下问题:PHP msp_get_the_resized_image_src函数的具体用法?PHP msp_get_the_resized_image_src怎么用?PHP msp_get_the_resized_image_src使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msp_get_the_resized_image_src函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_slide
public function parse_slide($slide = array())
{
// make sure $slide is not serialized
$slide = maybe_unserialize($slide);
if (empty($slide)) {
return $slide;
}
// get slider setting and controls
$slider_setting = $this->get_slider_setting();
// get slide onfo if is set (usage: for tab content if is set)
$info = isset($slide['info']) ? $slide['info'] : '';
if (isset($slide['bg'])) {
$slide_src = msp_get_the_absolute_media_url($slide['bg']);
// generate thumb for master slider panel
msp_get_the_resized_image_src($slide_src, 150, 150, true);
}
$thumb = '';
// add thumb just if thumblist is added to controls list
// also always add thumbnail if slider template is gallery
if ('true' == $slider_setting['thumbs'] && 'thumbs' == $slider_setting['thumbs_type'] || 'image-gallery' == $slider_setting['template']) {
if (isset($slide['thumb']) && !empty($slide['thumb'])) {
$thumb = $slide['thumb'];
$thumb = msp_get_the_relative_media_url($thumb);
} elseif (isset($slide['bg'])) {
// set custom thumb size if slider template is gallery
if ('image-gallery' == $slider_setting['template']) {
$thumb = msp_get_the_resized_image_src($slide_src, 175, 140, true);
} else {
$thumb = msp_get_the_resized_image_src($slide_src, $slider_setting['thumbs_width'], $slider_setting['thumbs_height'], true);
}
$thumb = msp_get_the_relative_media_url($thumb);
} else {
$thumb = '';
}
}
$slides = array('slide_order' => isset($slide['order']) ? (int) $slide['order'] : 0, 'css_class' => isset($slide['cssClass']) ? (string) $slide['cssClass'] : '', 'css_id' => isset($slide['cssId']) ? (string) $slide['cssId'] : '', 'ishide' => $this->is_key_true($slide, 'ishide', 'false'), 'src' => isset($slide['bg']) ? esc_attr(msp_get_the_relative_media_url($slide['bg'])) : '', 'src_full' => isset($slide['bg']) ? esc_attr(msp_get_the_relative_media_url($slide['bg'])) : '', 'title' => '', 'alt' => isset($slide['bgAlt']) ? esc_attr($slide['bgAlt']) : '', 'link' => isset($slide['link']) ? esc_attr($slide['link']) : '', 'target' => isset($slide['linkTarget']) ? (string) $slide['linkTarget'] : '', 'link_title' => isset($slide['linkTitle']) ? (string) $slide['linkTitle'] : '', 'link_class' => isset($slide['linkClass']) ? (string) $slide['linkClass'] : '', 'link_id' => isset($slide['linkId']) ? (string) $slide['linkId'] : '', 'link_rel' => isset($slide['linkRel']) ? (string) $slide['linkRel'] : '', 'video' => isset($slide['video']) ? esc_attr($slide['video']) : '', 'auto_play_video' => $this->is_key_true($slide, 'autoplayVideo', 'false'), 'info' => wp_slash(do_shortcode($info)), 'mp4' => isset($slide['bgv_mp4']) ? esc_attr($slide['bgv_mp4']) : '', 'webm' => isset($slide['bgv_webm']) ? esc_attr($slide['bgv_webm']) : '', 'ogg' => isset($slide['bgv_ogg']) ? esc_attr($slide['bgv_ogg']) : '', 'autopause' => $this->is_key_true($slide, 'bgv_autopause', 'false'), 'mute' => $this->is_key_true($slide, 'bgv_mute', 'true'), 'loop' => $this->is_key_true($slide, 'bgv_loop', 'true'), 'vbgalign' => isset($slide['bgv_fillmode']) ? (string) $slide['bgv_fillmode'] : 'fill', 'thumb' => $thumb, 'tab' => 'true' == $slider_setting['thumbs'] && 'tabs' == $slider_setting['thumbs_type'] ? str_replace('"', '"e;', $info) : '', 'delay' => isset($slide['duration']) ? (string) $slide['duration'] : '', 'bgalign' => isset($slide['fillMode']) ? (string) $slide['fillMode'] : 'fill', 'bgcolor' => isset($slide['bgColor']) ? (string) $slide['bgColor'] : '', 'pattern' => isset($slide['pattern']) ? (string) $slide['pattern'] : '', 'tintcolor' => isset($slide['colorOverlay']) ? (string) $slide['colorOverlay'] : '');
return $slides;
}
示例2: msp_masterslider_slide_shortcode
function msp_masterslider_slide_shortcode($atts, $content = null)
{
extract(shortcode_atts(array('src' => '', 'src_full' => '', 'css_class' => '', 'css_id' => '', 'style' => '', 'src_blank' => MSWP_BLANK_IMG, 'title' => '', 'alt' => '', 'link' => '', 'rel' => '', 'target' => '_blank', 'video' => '', 'auto_play_video' => '', 'mp4' => '', 'webm' => '', 'ogg' => '', 'info' => '', 'autopause' => 'false', 'mute' => 'true', 'loop' => 'true', 'vbgalign' => 'fill', 'crop_width' => '', 'crop_height' => '', 'thumb' => '', 'tab' => '', 'delay' => '', 'bgalign' => '', 'bgcolor' => '', 'pattern' => '', 'tintcolor' => ''), $atts, 'masterslider_slide'));
$css_class = empty($css_class) ? '' : ' ' . $css_class;
$css_id = empty($css_id) ? '' : 'id="' . $css_id . '"';
$style = esc_attr($style);
$style .= empty($bgcolor) ? '' : 'background-color:' . $bgcolor . ';';
$style_attr = empty($style) ? '' : 'style="' . $style . '"';
// create delay attr if is set
$data_delay = empty($delay) ? '' : 'data-delay="' . (double) $delay . '"';
// create bg align attr if is set
$data_align = empty($bgalign) ? '' : 'data-fill-mode="' . $bgalign . '"';
// add slide starter tag
$slide_start_tag = sprintf('<div %s class="ms-slide%s" %s %s %s >', $css_id, $css_class, $data_delay, $data_align, $style_attr) . "\n";
// making start tag filterable for extend purposes
$slide_start_tag = apply_filters('msp_masterslider_slide_start_tag', "\t\t\t\t" . $slide_start_tag, $atts);
// parse slide content ///////////////////////////////////////////
$slide_content = "";
// if blank image is not set use original img instead
$src_blank = empty($src_blank) ? $src : $src_blank;
if (!empty($pattern) || !empty($tintcolor)) {
$inline_style = !empty($tintcolor) ? 'style="background-color:' . $tintcolor . ';"' : '';
$slide_content .= "\t\t\t\t\t" . sprintf('<div class="ms-pattern %s" %s ></div>', $pattern, $inline_style) . "\n";
}
// main image markup
if (!empty($src)) {
$crop_width = empty($crop_width) || !is_numeric($crop_width) ? NULL : (int) $crop_width;
$crop_height = empty($crop_height) || !is_numeric($crop_height) ? NULL : (int) $crop_height;
if (strpos($src, '{{image}}') === false) {
$src = msp_get_the_absolute_media_url($src);
}
if ($crop_width || $crop_height) {
$src = msp_get_the_resized_image_src($src, $crop_width, $crop_height, true);
}
$slide_content .= "\t\t\t\t\t" . sprintf('<img src="%s" alt="%s" title="%s" data-src="%s" />', $src_blank, $alt, $title, $src) . "\n";
}
$self_video_markup = '';
// self host video background
if (!empty($mp4)) {
$self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/mp4"/>', $mp4) . "\n";
}
if (!empty($webm)) {
$self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/webm"/>', $webm) . "\n";
}
if (!empty($ogg)) {
$self_video_markup .= "\t\t" . sprintf('<source src="%s" type="video/ogg"/>', $ogg) . "\n";
}
if (!empty($self_video_markup)) {
$slide_content .= "\t" . sprintf('<video data-autopause="%s" data-mute="%s" data-loop="%s" data-fill-mode="%s" >%s%s%s</video>', msp_is_true($autopause), $mute, $loop, $vbgalign, "\n", $self_video_markup, "\t") . "\n";
}
// link markup
if (!empty($link)) {
$link = '{{slide-image-url}}' == $link ? msp_get_the_absolute_media_url($src_full) : esc_url($link);
$slide_content .= "\t" . sprintf('<a href="%s" target="%s" rel="%s" >%s</a>', $link, $target, $rel, $title) . "\n";
}
// add layers that passed as content
if (!empty($content)) {
$slide_content .= $content . "\n";
}
// thumb markup
if (!empty($thumb)) {
if (strpos($thumb, '{{thumb}}') === false) {
$thumb = msp_get_the_absolute_media_url($thumb);
}
$slide_content .= "\t" . sprintf('<img class="ms-thumb" src="%s" alt="%s" />', $thumb, $alt) . "\n";
}
// tab markup
if (!empty($tab)) {
$slide_content .= "\t" . sprintf('<div class="ms-thumb" >%s</div>', str_replace('"e;', '"', wp_specialchars_decode($tab))) . "\n";
}
// video markup
if (!empty($video)) {
// create data-autoplay attr if video autoplay is enabled
$data_auto_play_video = 'true' === $auto_play_video ? 'data-autoplay="' . $auto_play_video . '"' : '';
$slide_content .= "\t\t\t\t\t" . sprintf('<a href="%s" data-type="video" %s></a>', $video, $data_auto_play_video) . "\n";
}
// end slide content ////////////////////////////////////////////
$slide_end_tag = "\t\t\t\t</div>";
// making end tag filterable for extend purposes
$slide_end_tag = apply_filters("msp_masterslider_slide_end_tag", $slide_end_tag, $atts);
$slide_content = do_shortcode($slide_content);
$output = empty($slide_content) ? '' : $slide_start_tag . $slide_content . $slide_end_tag;
return apply_filters('masterslider_slide_content', $output, $slide_start_tag, $slide_content, $slide_end_tag);
}
示例3: parse_slide
public function parse_slide($slide = array())
{
// make sure $slide is not serialized
$slide = maybe_unserialize($slide);
if (empty($slide)) {
return $slide;
}
// get slider setting and controls
$slider_setting = $this->get_slider_setting();
// get slide onfo if is set (usage: for tab content if is set)
$info = isset($slide['info']) ? $slide['info'] : '';
if (isset($slide['bg'])) {
$slide_src = msp_get_the_absolute_media_url($slide['bg']);
// generate thumb for master slider panel
msp_get_the_resized_image_src($slide_src, 150, 150, true);
}
// stores a URL for thumbnail in thumbnail list
$thumb = '';
// add thumb just if thumblist is added to controls list
// also always add thumbnail if slider template is gallery
if ('true' == $slider_setting['thumbs'] && 'thumbs' == $slider_setting['thumbs_type'] || 'image-gallery' == $slider_setting['template']) {
if (isset($slide['thumbOrginal']) && !empty($slide['thumbOrginal'])) {
$thumb = $slide['thumbOrginal'];
$thumb = msp_get_the_relative_media_url($thumb);
} elseif (isset($slide['bg'])) {
// set custom thumb size if slider template is gallery
if ('image-gallery' == $slider_setting['template']) {
$thumb = msp_get_the_resized_image_src($slide_src, 175, 140, true);
} else {
$thumb = msp_get_the_resized_image_src($slide_src, $slider_setting['thumbs_width'], $slider_setting['thumbs_height'], true);
}
$thumb = msp_get_the_relative_media_url($thumb);
}
}
// stores a URL for thumbnail in tab
$tab_thumb = '';
// get thumb for tab if thumblist is added to controls list
if ('true' == $slider_setting['thumbs'] && 'tabs' == $slider_setting['thumbs_type'] && 'true' == $slider_setting['thumbs_in_tab']) {
if (isset($slide['thumbOrginal']) && !empty($slide['thumbOrginal'])) {
$tab_thumb = $slide['thumbOrginal'];
$tab_thumb = msp_get_the_relative_media_url($tab_thumb);
} elseif (isset($slide['bg'])) {
// generate a square thumb for tab
$tab_thumb = msp_get_the_resized_image_src($slide_src, $slider_setting['thumbs_height'], $slider_setting['thumbs_height'], true);
$tab_thumb = msp_get_the_relative_media_url($tab_thumb);
}
}
$slides = array('slide_order' => isset($slide['order']) ? (int) $slide['order'] : 0, 'css_class' => isset($slide['cssClass']) ? (string) $slide['cssClass'] : '', 'css_id' => isset($slide['cssId']) ? (string) $slide['cssId'] : '', 'ishide' => $this->is_key_true($slide, 'ishide', 'false'), 'src' => isset($slide['bg']) ? esc_attr(msp_get_the_relative_media_url($slide['bg'])) : '', 'src_full' => isset($slide['bg']) ? esc_attr(msp_get_the_relative_media_url($slide['bg'])) : '', 'title' => '', 'alt' => isset($slide['bgAlt']) ? esc_attr($slide['bgAlt']) : '', 'link' => isset($slide['link']) ? esc_attr($slide['link']) : '', 'target' => isset($slide['linkTarget']) ? (string) $slide['linkTarget'] : '', 'link_title' => isset($slide['linkTitle']) ? (string) $slide['linkTitle'] : '', 'link_class' => isset($slide['linkClass']) ? (string) $slide['linkClass'] : '', 'link_id' => isset($slide['linkId']) ? (string) $slide['linkId'] : '', 'link_rel' => isset($slide['linkRel']) ? (string) $slide['linkRel'] : '', 'video' => isset($slide['video']) ? esc_attr($slide['video']) : '', 'auto_play_video' => $this->is_key_true($slide, 'autoplayVideo', 'false'), 'info' => wp_slash($info), 'mp4' => isset($slide['bgv_mp4']) ? esc_attr($slide['bgv_mp4']) : '', 'webm' => isset($slide['bgv_webm']) ? esc_attr($slide['bgv_webm']) : '', 'ogg' => isset($slide['bgv_ogg']) ? esc_attr($slide['bgv_ogg']) : '', 'autopause' => $this->is_key_true($slide, 'bgv_autopause', 'false'), 'mute' => $this->is_key_true($slide, 'bgv_mute', 'true'), 'loop' => $this->is_key_true($slide, 'bgv_loop', 'true'), 'vbgalign' => isset($slide['bgv_fillmode']) ? (string) $slide['bgv_fillmode'] : 'fill', 'thumb' => $thumb, 'tab' => 'true' == $slider_setting['thumbs'] && 'tabs' == $slider_setting['thumbs_type'] ? str_replace('"', '"e;', $info) : '', 'tab_thumb' => $tab_thumb, 'delay' => isset($slide['duration']) ? (string) $slide['duration'] : '', 'bgalign' => isset($slide['fillMode']) ? (string) $slide['fillMode'] : 'fill', 'bgcolor' => isset($slide['bgColor']) ? (string) $slide['bgColor'] : '', 'pattern' => isset($slide['pattern']) ? (string) $slide['pattern'] : '', 'tintcolor' => isset($slide['colorOverlay']) ? (string) $slide['colorOverlay'] : '', 'layer_ids' => isset($slide['layer_ids']) && !empty($slide['layer_ids']) ? (array) $slide['layer_ids'] : array(), 'layers' => array());
// get all layers in slider
$all_layers = $this->get_layers();
// store slide's layers
$current_layers = array();
// select the layers that belongs to this slide
foreach ($slides['layer_ids'] as $layer_id) {
if (isset($all_layers[$layer_id])) {
$current_layers[] = $all_layers[$layer_id];
}
}
// stores layers by layer order
$layers_by_order = array();
// collect layers by layer order
foreach ($current_layers as $layer) {
$layers_by_order[$layer['order']] = $layer;
}
// sort layers by layer order
ksort($layers_by_order);
// replace real layers data with layers id
$slides['layers'] = $layers_by_order;
return $slides;
}
示例4: get_wc_slider_ms_slides_shortcode
public function get_wc_slider_ms_slides_shortcode()
{
if (!isset($this->parsed_slider_data['slides'])) {
return '';
}
$slides = $this->parsed_slider_data['slides'];
$query = array();
$query['image_from'] = $this->parsed_slider_data['setting']['ps_image_from'];
$query['excerpt_length'] = $this->parsed_slider_data['setting']['ps_excerpt_len'];
$exclude_posts_no_img = $this->parsed_slider_data['setting']['ps_exclude_no_img'];
$query['only_featured'] = $this->parsed_slider_data['setting']['wc_only_featured'];
$query['only_instock'] = $this->parsed_slider_data['setting']['wc_only_instock'];
$query['only_onsale'] = $this->parsed_slider_data['setting']['wc_only_onsale'];
if (!empty($this->parsed_slider_data['setting']['ps_post_type'])) {
$query['post_type'] = $this->parsed_slider_data['setting']['ps_post_type'];
}
$query['orderby'] = $this->parsed_slider_data['setting']['ps_orderby'];
$query['order'] = $this->parsed_slider_data['setting']['ps_order'];
$query['posts_per_page'] = $this->parsed_slider_data['setting']['ps_post_count'];
if (!empty($this->parsed_slider_data['setting']['ps_posts_not_in'])) {
$posts_not_in = explode(',', $this->parsed_slider_data['setting']['ps_posts_not_in']);
$query['post__not_in'] = array_filter($posts_not_in);
}
if (!empty($this->parsed_slider_data['setting']['ps_posts_in'])) {
$posts_in = explode(',', $this->parsed_slider_data['setting']['ps_posts_in']);
$query['post__in'] = array_filter($posts_in);
}
$query['offset'] = $this->parsed_slider_data['setting']['ps_offset'];
$taxs_data = array();
if (!empty($this->parsed_slider_data['setting']['ps_tax_term_ids'])) {
$taxs_data = explode(',', $this->parsed_slider_data['setting']['ps_tax_term_ids']);
}
$tax_query = array();
$wcs = msp_get_wc_slider_class();
$query['tax_query'] = $wcs->get_tax_query($taxs_data);
$query['image_size'] = 'full';
$query = apply_filters('msp_wc_slider_query_args', $query, $this->parsed_slider_data);
$this->post_slider_args = $query;
$slides_shortcode = '';
$th_wp_query = $wcs->get_query_results($query);
if ($th_wp_query->have_posts()) {
while ($th_wp_query->have_posts()) {
$th_wp_query->the_post();
$product = get_product($th_wp_query->post);
$slide_content = '';
$attrs = '';
$this->post_id = $th_wp_query->post->ID;
if (empty($this->parsed_slider_data['setting']['ps_slide_bg'])) {
$the_media = msp_get_auto_post_thumbnail_url($th_wp_query->post, $query['image_from']);
} else {
$the_media = $this->parsed_slider_data['setting']['ps_slide_bg'];
}
// skip this post if it does not have image and $exclude_posts_no_img is enabled
if (empty($the_media) && 'true' == $exclude_posts_no_img) {
continue;
}
$attrs .= sprintf('%s="%s" ', 'src', esc_attr($the_media));
// generate slide_info shortcode if slideinfo control is added
if (isset($this->parsed_slider_data['setting']['slideinfo']) && 'true' == $this->parsed_slider_data['setting']['slideinfo']) {
if (!empty($slides['0']['info'])) {
$slide_info = preg_replace_callback('/{{[\\w-]+}}/', array($this, 'do_template_tag'), $slides['0']['info']);
} else {
$slide_info = " ";
}
$slide_content .= $this->get_ms_slide_info_shortcode($slide_info);
}
if ($this->parsed_slider_data['setting']['ps_link_slide']) {
$attrs .= sprintf('%s="%s" ', 'link', get_the_permalink($th_wp_query->post->ID));
}
$attrs .= sprintf('%s="%s" ', 'title', $this->escape_square_brackets(get_the_title($th_wp_query->post->ID)));
$attrs .= sprintf('%s="%s" ', 'alt', $this->escape_square_brackets(get_the_title($th_wp_query->post->ID)));
$attrs .= sprintf('%s="%s" ', 'target', $this->parsed_slider_data['setting']['ps_link_target']);
$attrs .= sprintf('%s="%s" ', 'delay', $slides['0']['delay']);
// bg color and align for slides
$attrs .= sprintf('%s="%s" ', 'bgalign', $slides['0']['bgalign']);
$attrs .= sprintf('%s="%s" ', 'bgcolor', $slides['0']['bgcolor']);
if ('true' == $this->parsed_slider_data['setting']['thumbs']) {
if ('thumbs' == $this->parsed_slider_data['setting']['thumbs_type']) {
if (!empty($the_media)) {
// set custom thumb size if slider template is gallery
if ('image-gallery' == $this->parsed_slider_data['setting']['template']) {
$thumb = msp_get_the_resized_image_src($the_media, 175, 140, true);
} else {
$thumb = msp_get_the_resized_image_src($the_media, $this->parsed_slider_data['setting']['thumbs_width'], $this->parsed_slider_data['setting']['thumbs_height'], true);
}
$thumb = msp_get_the_relative_media_url($thumb);
$attrs .= sprintf('%s="%s" ', 'thumb', $thumb);
} else {
$tab = '<div class="ms-thumb-alt">' . get_the_title($th_wp_query->post->ID) . '</div>';
$attrs .= sprintf('%s="%s" ', 'tab', $tab);
}
} elseif ('tabs' == $this->parsed_slider_data['setting']['thumbs_type']) {
// if "insert thumb" option was enabled generate and add the thumbnail
if ('true' == $this->parsed_slider_data['setting']['thumbs_in_tab']) {
$thumb_height = $this->parsed_slider_data['setting']['thumbs_height'];
$tab_thumb = msp_get_auto_post_thumbnail_url($th_wp_query->post, 'featured', array($thumb_height, $thumb_height), true);
$attrs .= sprintf('%s="%s" ', 'tab_thumb', $tab_thumb);
}
if (!empty($slides['0']['info'])) {
$tab_context = preg_replace_callback('/{{[\\w-]+}}/', array($this, 'do_template_tag'), $slides['0']['info']);
//.........这里部分代码省略.........
示例5: gallery_output
//.........这里部分代码省略.........
$slider_attrs['slideinfo_height'] = '30';
$slider_attrs['skin'] = $atts['skin'];
$slider_attrs['preload'] = $atts['preload'];
$slider_attrs['auto_height'] = $atts['auto_height'];
// Whether thumbail is enables or not
$has_thumb = 'true' === $atts['thumbs'];
$has_tab = !$has_thumb && 'tabs' === $atts['thumbs_type'];
$has_slideinfo = 'true' === $atts['caption'];
// Add thumbnail options id enabled
if ($has_thumb) {
$slider_attrs['thumbs'] = $atts['thumbs'];
$slider_attrs['thumbs_type'] = $atts['thumbs_type'];
$slider_attrs['thumbs_align'] = $atts['thumbs_align'];
$slider_attrs['thumbs_width'] = $atts['thumbs_width'];
$slider_attrs['thumbs_height'] = $atts['thumbs_height'];
$slider_attrs['thumbs_space'] = $atts['thumbs_space'];
$slider_attrs['thumbs_inset'] = $atts['thumbs_inset'];
$slider_attrs['thumbs_autohide'] = $atts['thumbs_autohide'];
$slider_attrs['thumbs_margin'] = $atts['thumbs_margin'];
if ('bottom' == $slider_attrs['thumbs_align']) {
$slider_attrs['slideinfo_margin'] = '80';
}
} elseif ($has_tab) {
$slider_attrs['thumbs_type'] = 'tabs';
}
if ($has_slideinfo) {
$slider_attrs['slideinfo'] = 'true';
$slider_attrs['slideinfo_inset'] = 'true';
$slider_attrs['slideinfo_height'] = '30';
}
// get attachments
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']));
}
// skip if no attachments found
if (empty($attachments)) {
return '';
}
$slides_shortcode = '';
foreach ($attachments as $id => $attachment) {
$attrs = '';
$img_src = msp_get_the_resized_attachment_src($id, 1400);
$attrs .= sprintf('%s="%s" ', 'src', $img_src);
$attrs .= sprintf('%s="%s" ', 'src_full', $img_src);
if ('file' == $atts['link']) {
$link = $img_src;
} elseif ('none' == $atts['link']) {
$link = '';
} else {
$link = get_permalink($id);
}
if (!empty($link)) {
$attrs .= sprintf('%s="%s" ', 'link', $link);
}
$info = '';
if (empty($attachment->post_excerpt)) {
$attrs .= sprintf('%s="%s" ', 'alt', $attachment->post_excerpt);
} else {
$attrs .= sprintf('%s="%s" ', 'alt', $attachment->post_title);
}
if ($has_slideinfo) {
$caption = $attachment->post_excerpt ? $attachment->post_excerpt : $attachment->post_title;
$info = sprintf('[ms_slide_info]%s[/ms_slide_info]%s', $caption, "\n");
}
$attrs .= sprintf('%s="%s" ', 'target', $atts['target']);
$attrs .= sprintf('%s="%s" ', 'delay', $atts['delay']);
if ($has_thumb) {
$thumb = msp_get_the_resized_image_src($img_src, $atts['thumbs_width'], $atts['thumbs_height'], true);
$thumb = msp_get_the_relative_media_url($thumb);
$attrs .= sprintf('%s="%s" ', 'thumb', $thumb);
} elseif ($has_tab) {
$tab = '<div class="ms-thumb-alt">' . $attachment->post_title . '</div>';
$attrs .= sprintf('%s="%s" ', 'tab', $tab);
}
$slides_shortcode .= sprintf('[ms_slide %1$s]%3$s%2$s[/ms_slide]%3$s', $attrs, $info, "\n");
}
/**
* Filter slider default attributes. To find full list of slider options, take a look at "msp_masterslider_wrapper_shortcode"
* function in /includes/msp-shortcodes.php file
*
* @var array List of slider options with values
*/
$slider_attrs = apply_filters('masterslider_gallery_slider_attrs', $slider_attrs);
// Convert attrs to string
$slides_shortcode_attrs = '';
foreach ($slider_attrs as $slider_attr => $slider_attr_value) {
$slides_shortcode_attrs .= sprintf('%s="%s" ', $slider_attr, $slider_attr_value);
}
// Create slider shortcode
$gallery_slider_shortcode = sprintf('[ms_slider %1$s]%2$s%3$s[/ms_slider]', $slides_shortcode_attrs, "\n", $slides_shortcode);
return do_shortcode($gallery_slider_shortcode);
}
示例6: foreach
foreach ($attachment_ids as $attachment_id) {
$image_link = wp_get_attachment_url($attachment_id);
if (!$image_link) {
continue;
}
$image_title = esc_attr(get_the_title($attachment_id));
$image_src = msp_get_the_resized_image_src($image_link, $slide_image_dimensions['width'], $slide_image_dimensions['height'], $slide_image_dimensions['crop']);
$attachment_count = count($product->get_gallery_attachment_ids());
if ($attachment_count > 0) {
$gallery = "[product-gallery]";
} else {
$gallery = '';
}
$slide_options = array('src' => $image_src, 'css_class' => 'zoom ms-zoom', 'title' => $image_title, 'alt' => $image_title, 'rel' => 'prettyPhoto' . $gallery, 'target' => '_blank', 'video' => '', 'mp4' => '', 'webm' => '', 'ogg' => '', 'autopause' => 'false', 'mute' => 'true', 'loop' => 'true', 'crop_width' => '', 'crop_height' => '', 'thumb' => '', 'delay' => '', 'bgalign' => '');
if ($enable_thumbnail) {
$slide_options['thumb'] = msp_get_the_resized_image_src($image_link, $thumbnail_dimensions['width'], $thumbnail_dimensions['height'], $thumbnail_dimensions['crop']);
}
$slide_options = apply_filters('msp_woocommerce_single_product_slider_slide_params', $slide_options, $post);
$slide_attrs = '';
foreach ($slide_options as $attr => $attr_value) {
$slide_attrs .= sprintf('%s="%s" ', $attr, esc_attr($attr_value));
}
$slides .= sprintf('[ms_slide %s ][/ms_slide]', $slide_attrs);
$loop++;
}
}
$slider_shortcode = !empty($slides) ? sprintf('[ms_slider %s ]%s[/ms_slider]', $slider_attrs, $slides) : '';
echo do_shortcode($slider_shortcode);
} elseif ($image_count === 1) {
if (has_post_thumbnail()) {
$image_title = esc_attr(get_the_title(get_post_thumbnail_id()));