Example #1
0
 /**
  * @param array $settings [ image => [ id => '', url => '' ], image_size => '', hover_animation => '' ]
  *
  * @return string
  */
 public static function get_attachment_image_html($settings)
 {
     $id = $settings['image']['id'];
     $url = $settings['image']['url'];
     // Old version of image settings
     if (!isset($settings['image_size'])) {
         $settings['image_size'] = '';
     }
     $size = $settings['image_size'];
     $image_class = !empty($settings['hover_animation']) ? 'elementor-animation-' . $settings['hover_animation'] : '';
     $html = '';
     // If is the new version - with image size
     $image_sizes = get_intermediate_image_sizes();
     $image_sizes[] = 'full';
     if (!empty($id) && in_array($size, $image_sizes)) {
         $image_class .= " attachment-{$size} size-{$size}";
         $html .= wp_get_attachment_image($id, $size, false, ['class' => trim($image_class)]);
     } else {
         $image_src = Group_Control_Image_Size::get_attachment_image_src($id, 'image', $settings);
         if (!$image_src) {
             $image_src = $url;
         }
         $image_class_html = !empty($image_class) ? ' class="' . $image_class . '"' : '';
         $html .= sprintf('<img src="%s" title="%s" alt="%s"%s />', esc_attr($image_src), Control_Media::get_image_title($settings['image']), Control_Media::get_image_alt($settings['image']), $image_class_html);
     }
     return $html;
 }
Example #2
0
 protected function render()
 {
     $settings = $this->get_settings();
     $has_content = !empty($settings['title_text']) || !empty($settings['description_text']);
     $html = '<div class="elementor-image-box-wrapper">';
     if (!empty($settings['image']['url'])) {
         $this->add_render_attribute('image', 'src', $settings['image']['url']);
         $this->add_render_attribute('image', 'alt', Control_Media::get_image_alt($settings['image']));
         $this->add_render_attribute('image', 'title', Control_Media::get_image_title($settings['image']));
         if ($settings['hover_animation']) {
             $this->add_render_attribute('image', 'class', 'elementor-animation-' . $settings['hover_animation']);
         }
         $image_html = '<img ' . $this->get_render_attribute_string('image') . '>';
         if (!empty($settings['link']['url'])) {
             $target = '';
             if (!empty($settings['link']['is_external'])) {
                 $target = ' target="_blank"';
             }
             $image_html = sprintf('<a href="%s"%s>%s</a>', $settings['link']['url'], $target, $image_html);
         }
         $html .= '<figure class="elementor-image-box-img">' . $image_html . '</figure>';
     }
     if ($has_content) {
         $html .= '<div class="elementor-image-box-content">';
         if (!empty($settings['title_text'])) {
             $title_html = $settings['title_text'];
             if (!empty($settings['link']['url'])) {
                 $target = '';
                 if (!empty($settings['link']['is_external'])) {
                     $target = ' target="_blank"';
                 }
                 $title_html = sprintf('<a href="%s"%s>%s</a>', $settings['link']['url'], $target, $title_html);
             }
             $html .= sprintf('<%1$s class="elementor-image-box-title">%2$s</%1$s>', $settings['title_size'], $title_html);
         }
         if (!empty($settings['description_text'])) {
             $html .= sprintf('<p class="elementor-image-box-description">%s</p>', $settings['description_text']);
         }
         $html .= '</div>';
     }
     $html .= '</div>';
     echo $html;
 }
Example #3
0
    protected function render()
    {
        $settings = $this->get_settings();
        if (empty($settings['carousel'])) {
            return;
        }
        $slides = [];
        foreach ($settings['carousel'] as $attachment) {
            $image_url = Group_Control_Image_Size::get_attachment_image_src($attachment['id'], 'thumbnail', $settings);
            $image_html = '<img class="slick-slide-image" src="' . esc_attr($image_url) . '" alt="' . esc_attr(Control_Media::get_image_alt($attachment)) . '" />';
            $link = $this->get_link_url($attachment, $settings);
            if ($link) {
                $target = '';
                if (!empty($link['is_external'])) {
                    $target = ' target="_blank"';
                }
                $image_html = sprintf('<a href="%s"%s>%s</a>', $link['url'], $target, $image_html);
            }
            $slides[] = '<div><div class="slick-slide-inner">' . $image_html . '</div></div>';
        }
        if (empty($slides)) {
            return;
        }
        $is_slideshow = '1' === $settings['slides_to_show'];
        $is_rtl = 'rtl' === $settings['direction'];
        $direction = $is_rtl ? 'rtl' : 'ltr';
        $show_dots = in_array($settings['navigation'], ['dots', 'both']);
        $show_arrows = in_array($settings['navigation'], ['arrows', 'both']);
        $slick_options = ['slidesToShow' => absint($settings['slides_to_show']), 'autoplaySpeed' => absint($settings['autoplay_speed']), 'autoplay' => 'yes' === $settings['autoplay'], 'infinite' => 'yes' === $settings['infinite'], 'pauseOnHover' => 'yes' === $settings['pause_on_hover'], 'speed' => absint($settings['speed']), 'arrows' => $show_arrows, 'dots' => $show_dots, 'rtl' => $is_rtl];
        $carousel_classes = ['elementor-image-carousel'];
        if ($show_arrows) {
            $carousel_classes[] = 'slick-arrows-' . $settings['arrows_position'];
        }
        if ($show_dots) {
            $carousel_classes[] = 'slick-dots-' . $settings['dots_position'];
        }
        if ('yes' === $settings['image_stretch']) {
            $carousel_classes[] = 'slick-image-stretch';
        }
        if (!$is_slideshow) {
            $slick_options['slidesToScroll'] = absint($settings['slides_to_scroll']);
        } else {
            $slick_options['fade'] = 'fade' === $settings['effect'];
        }
        ?>
		<div class="elementor-image-carousel-wrapper elementor-slick-slider" dir="<?php 
        echo $direction;
        ?>
">
			<div class="<?php 
        echo implode(' ', $carousel_classes);
        ?>
" data-slider_options='<?php 
        echo wp_json_encode($slick_options);
        ?>
'>
				<?php 
        echo implode('', $slides);
        ?>
			</div>
		</div>
	<?php 
    }
Example #4
0
    protected function render()
    {
        $settings = $this->get_settings();
        if (empty($settings['testimonial_name']) || empty($settings['testimonial_content'])) {
            return;
        }
        $has_image = false;
        if ('' !== $settings['testimonial_image']['url']) {
            $image_url = $settings['testimonial_image']['url'];
            $has_image = ' elementor-has-image';
        }
        $testimonial_alignment = $settings['testimonial_alignment'] ? ' elementor-testimonial-text-align-' . $settings['testimonial_alignment'] : '';
        $testimonial_image_position = $settings['testimonial_image_position'] ? ' elementor-testimonial-image-position-' . $settings['testimonial_image_position'] : '';
        ?>
		<div class="elementor-testimonial-wrapper<?php 
        echo $testimonial_alignment;
        ?>
">

			<?php 
        if (!empty($settings['testimonial_content'])) {
            ?>
				<div class="elementor-testimonial-content">
						<?php 
            echo $settings['testimonial_content'];
            ?>
				</div>
			<?php 
        }
        ?>

			<div class="elementor-testimonial-meta<?php 
        if ($has_image) {
            echo $has_image;
        }
        echo $testimonial_image_position;
        ?>
">
				<div class="elementor-testimonial-meta-inner">
					<?php 
        if (isset($image_url)) {
            ?>
						<div class="elementor-testimonial-image">
							<img src="<?php 
            echo esc_attr($image_url);
            ?>
" alt="<?php 
            echo esc_attr(Control_Media::get_image_alt($settings['testimonial_image']));
            ?>
" />
						</div>
					<?php 
        }
        ?>

					<div class="elementor-testimonial-details">
						<?php 
        if (!empty($settings['testimonial_name'])) {
            ?>
							<div class="elementor-testimonial-name">
								<?php 
            echo $settings['testimonial_name'];
            ?>
							</div>
						<?php 
        }
        ?>

						<?php 
        if (!empty($settings['testimonial_job'])) {
            ?>
							<div class="elementor-testimonial-job">
								<?php 
            echo $settings['testimonial_job'];
            ?>
							</div>
						<?php 
        }
        ?>
					</div>
				</div>
			</div>
		</div>
	<?php 
    }