/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $html_elemments = $script = ''; $image_styles = array(); if ($image_margin_top) { $image_styles[] = "margin-top:{$image_margin_top}px"; } if ($image_margin_bottom) { $image_styles[] = "margin-bottom:{$image_margin_bottom}px"; } if ($image_margin_right) { $image_styles[] = "margin-right:{$image_margin_right}px"; } if ($image_margin_left) { $image_styles[] = "margin-left:{$image_margin_left}px"; } $styles = count($image_styles) ? ' style="' . implode(';', $image_styles) . '"' : ''; if ($image_file) { $html_elemments .= "<div class='contact-img-wrapper {$image_container_style}'>"; $image_id = IG_Pb_Helper_Functions::get_image_id($image_file); $attachment = wp_prepare_attachment_for_js($image_id); $image_file = !empty($attachment['sizes'][$image_size]['url']) ? $attachment['sizes'][$image_size]['url'] : $image_file; $html_elemments .= "<img src='{$image_file}'{$alt_text}{$styles}{$class_img} />"; $script = ''; $target = ''; $sub_shortcode = IG_Pb_Helper_Shortcode::remove_autop($content); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); if ($items) { $buttons = "" . implode('', $items) . ''; $html_elemments .= "<div class='btns-wrapper'><div class='contact-btns'>" . $buttons . "</div><div class='vertical-helper'></div></div>"; } $html_elemments .= '</div>'; if (strtolower($image_alignment) != 'inherit') { if (strtolower($image_alignment) == 'left') { $cls_alignment = 'pull-left'; } if (strtolower($image_alignment) == 'right') { $cls_alignment = 'pull-right'; } if (strtolower($image_alignment) == 'center') { $cls_alignment = 'text-center'; } $html_elemments = "<div class='{$cls_alignment}'>" . $html_elemments . '</div>'; } } return $this->element_wrapper($html_elemments . $script, $arr_params); }
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $html_elemments = $script = ''; $alt_text = $image_alt ? " alt='{$image_alt}'" : ''; $image_styles = array(); if ($image_margin_top) { $image_styles[] = "margin-top:{$image_margin_top}px"; } if ($image_margin_bottom) { $image_styles[] = "margin-bottom:{$image_margin_bottom}px"; } if ($image_margin_right) { $image_styles[] = "margin-right:{$image_margin_right}px"; } if ($image_margin_left) { $image_styles[] = "margin-left:{$image_margin_left}px"; } $styles = count($image_styles) ? ' style="' . implode(';', $image_styles) . '"' : ''; $class_img = $image_container_style != 'no-styling' ? $image_container_style : ''; $class_img = $image_effect == 'yes' ? $class_img . ' image-scroll-fade' : $class_img; $class_img = !empty($class_img) ? ' class="' . $class_img . '"' : ''; if ($image_file) { $image_id = IG_Pb_Helper_Functions::get_image_id($image_file); $attachment = wp_prepare_attachment_for_js($image_id); $image_file = !empty($attachment['sizes'][$image_size]['url']) ? $attachment['sizes'][$image_size]['url'] : $image_file; $html_elemments .= "<img src='{$image_file}'{$alt_text}{$styles}{$class_img} />"; $script = ''; $target = ''; if ($image_effect == 'yes' and !isset($_POST['action'])) { $data = getimagesize($image_file); $width = $data[0]; $height = $data[1]; $html_elemments = "<img src='" . IG_Pb_Helper_Functions::path('assets/3rd-party') . '/jquery-lazyload/grey.gif' . "' data-original='{$image_file}' width='{$width}' height='{$height}' {$alt_text}{$styles} {$class_img}/>"; } if ($open_in) { switch ($open_in) { case 'current_browser': $target = ''; break; case 'new_browser': $target = ' target="_blank"'; break; case 'lightbox': $cls_button_fancy = 'ig-image-fancy'; break; } } $class = isset($cls_button_fancy) && !empty($cls_button_fancy) ? " class='{$cls_button_fancy}'" : ''; // get Single Item and check type to get right link $single_item = explode('__#__', $single_item); $single_item = $single_item[0]; $taxonomies = IG_Pb_Helper_Type::get_public_taxonomies(); $post_types = IG_Pb_Helper_Type::get_post_types(); // single post if (array_key_exists($link_type, $post_types)) { $permalink = home_url() . "/?p={$single_item}"; $html_elemments = "<a href='{$permalink}'{$target}{$class}>" . $html_elemments . '</a>'; } else { if (array_key_exists($link_type, $taxonomies)) { $permalink = get_term_link(intval($single_item), $link_type); if (!is_wp_error($permalink)) { $html_elemments = "<a href='{$permalink}'{$target}{$class}>" . $html_elemments . '</a>'; } } else { switch ($link_type) { case 'url': $html_elemments = "<a href='{$image_type_url}'{$target}{$class}>" . $html_elemments . '</a>'; break; case 'large_image': $image_id = IG_Pb_Helper_Functions::get_image_id($image_file); $attachment = wp_prepare_attachment_for_js($image_id); $image_url = !empty($attachment['sizes'][$image_image_size]['url']) ? $attachment['sizes'][$image_image_size]['url'] : $image_file; $html_elemments = "<a href='{$image_url}'{$target}{$class}>" . $html_elemments . '</a>'; break; } } } if (strtolower($image_alignment) != 'inherit') { if (strtolower($image_alignment) == 'left') { $cls_alignment = 'pull-left'; } if (strtolower($image_alignment) == 'right') { $cls_alignment = 'pull-right'; } if (strtolower($image_alignment) == 'center') { $cls_alignment = 'text-center'; } $html_elemments = "<div class='{$cls_alignment}'>" . $html_elemments . '</div>'; } } return $this->element_wrapper($html_elemments . $script, $arr_params); }
public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); extract($arr_params); $html_elemments = $script = ''; $alt_text = $image_alt ? " alt='{$image_alt}'" : 'alt=""'; $image_styles = array(); if ($image_margin_top) { $image_styles[] = "margin-top:{$image_margin_top}px"; } if ($image_margin_bottom) { $image_styles[] = "margin-bottom:{$image_margin_bottom}px"; } if ($image_margin_right) { $image_styles[] = "margin-right:{$image_margin_right}px"; } if ($image_margin_left) { $image_styles[] = "margin-left:{$image_margin_left}px"; } $styles = count($image_styles) ? ' style="' . implode(';', $image_styles) . '"' : ''; $class_img = $image_container_style != 'no-styling' ? $image_container_style : ''; $class_img = $image_effect == 'yes' ? $class_img . ' image-scroll-fade' : $class_img; $class_img = !empty($class_img) ? ' class="' . $class_img . '"' : ''; if ($image_type == 'banner') { $img_banner = ' data-image-type="banner" data-image-text="' . $banner_text . '" '; } if ($image_file) { $image_id = IG_Pb_Helper_Functions::get_image_id($image_file); $attachment = wp_prepare_attachment_for_js($image_id); $image_file = !empty($attachment['sizes'][$image_size]['url']) ? $attachment['sizes'][$image_size]['url'] : $image_file; if ($image_type != 'banner_wel') { $html_elemments .= "<img src='{$image_file}'{$alt_text}{$styles}{$class_img}{$img_banner} />"; } else { $html_elemments .= "<div class=\"wel-banner\"><img src='{$image_file}'{$alt_text}{$styles}{$class_img} />\n <div class=\"wel-b-overlay\">{$welcome_text}</div>\n </div>"; } $script = ''; $target = ''; if ($open_in) { switch ($open_in) { case 'current_browser': $target = ''; break; case 'new_browser': $target = ' target="_blank"'; break; case 'lightbox': $cls_button_fancy = ' pt-image-fancy'; $img_gal = ' rel="prettyPhoto" '; break; } } $class = !empty($cls_button_fancy) ? "class='{$cls_button_fancy}'" : ''; $img_gal = !empty($img_gal) ? $img_gal : ''; // get Single Item and check type to get right link @($single_item = explode('__#__', $single_item)); $single_item = $single_item[0]; $taxonomies = IG_Pb_Helper_Type::get_public_taxonomies(); $post_types = IG_Pb_Helper_Type::get_post_types(); // single post if (array_key_exists($link_type, $post_types)) { $permalink = home_url() . "/?p={$single_item}"; $html_elemments = "<a href='{$permalink}'{$target}{$class}{$img_gal}>" . $html_elemments . '</a>'; } else { if (array_key_exists($link_type, $taxonomies)) { $permalink = get_term_link(intval($single_item), $link_type); if (!is_wp_error($permalink)) { $html_elemments = "<a href='{$permalink}'{$target}{$class}{$img_gal}>" . $html_elemments . '</a>'; } } else { switch ($link_type) { case 'url': $html_elemments = "<a href='{$image_type_url}'{$target}{$class}{$img_gal}>" . $html_elemments . '</a>'; break; case 'large_image': $image_id = IG_Pb_Helper_Functions::get_image_id($image_file); $attachment = wp_prepare_attachment_for_js($image_id); $image_url = !empty($attachment['sizes'][$image_image_size]['url']) ? $attachment['sizes'][$image_image_size]['url'] : $image_file; $html_elemments = "<a href='{$image_url}'{$target}{$class}{$img_gal}>" . $html_elemments . '</a>'; break; } } } if (strtolower($image_alignment) != 'inherit') { if (strtolower($image_alignment) == 'left') { $cls_alignment = 'pull-left'; } if (strtolower($image_alignment) == 'right') { $cls_alignment = 'pull-right'; } if (strtolower($image_alignment) == 'center') { $cls_alignment = 'text-center'; } $html_elemments = "<div class='{$cls_alignment}'>" . $html_elemments . '</div>'; } } return $this->element_wrapper($html_elemments . $script, $arr_params); }
/** * Get image size * * @param array $post_request * @return string */ function get_image_size($post_request) { $response = ''; $image_url = $post_request['image_url']; if ($image_url) { $image_id = IG_Pb_Helper_Functions::get_image_id($image_url); $attachment = wp_prepare_attachment_for_js($image_id); if ($attachment['sizes']) { $sizes = $attachment['sizes']; $attachment['sizes'] = null; foreach ($sizes as $key => $item) { $item['total_size'] = $item['height'] + $item['width']; $attachment['sizes'][ucfirst($key)] = $item; } } $response = json_encode($attachment); } return $response; }