Exemplo n.º 1
0
 /**
  * Returns logo <img> tag or empty string if something gone wrong.
  * @since 3.0.0
  * @param  array  $logos
  * @param  string $class
  * @return string
  */
 function presscore_get_logo_image($logos = array(), $class = '')
 {
     $default_logo = null;
     if (!is_array($logos)) {
         $logos = array($logos);
     }
     // get default logo
     foreach ($logos as $logo) {
         if ($logo) {
             $default_logo = $logo;
             break;
         }
     }
     if (empty($default_logo)) {
         return '';
     }
     $alt = esc_attr(get_bloginfo('name'));
     if (presscore_is_srcset_based_retina() || presscore_is_logos_only_retina()) {
         $logo = presscore_get_image_with_srcset($logos['logo'], $logos['logo_retina'], $default_logo, ' alt="' . $alt . '"', $class);
     } else {
         $logo = dt_get_retina_sensible_image($logos['logo'], $logos['logo_retina'], $default_logo, ' alt="' . $alt . '"', $class);
     }
     return $logo;
 }
Exemplo n.º 2
0
 public function render_logo($attributes = array())
 {
     $post_id = get_the_ID();
     if (!$post_id) {
         return '';
     }
     $html = '';
     $images = array('normal' => null, 'retina' => null);
     $image_classes = array();
     $esc_title = esc_attr(get_the_title());
     $thumb_id = 0;
     // get featured image
     if (has_post_thumbnail($post_id)) {
         $thumb_id = get_post_thumbnail_id($post_id);
         $images['normal'] = wp_get_attachment_image_src($thumb_id, 'full');
     }
     // get retina image
     $retina_logo_id = get_post_meta($post_id, '_dt_logo_options_retina_logo', true);
     if ($retina_logo_id) {
         $images['retina'] = dt_get_uploaded_logo(array('', $retina_logo_id[0]), 'retina');
     }
     // default image
     $default_img = null;
     foreach ($images as $image) {
         if ($image) {
             $default_img = $image;
             break;
         }
     }
     if (!$default_img) {
         return '';
     }
     if (presscore_shortcode_animation_on($attributes['animation'])) {
         $image_classes[] = presscore_get_shortcode_animation_html_class($attributes['animation']);
     }
     // ninjaaaa!
     $image_classes = implode(' ', $image_classes);
     // final image
     if (presscore_is_srcset_based_retina()) {
         $image = presscore_get_image_with_srcset($images['normal'], $images['retina'], $default_img, 'alt="' . $esc_title . '"', esc_attr($image_classes));
     } else {
         $image = dt_get_retina_sensible_image($images['normal'], $images['retina'], $default_img, 'alt="' . $esc_title . '"', esc_attr($image_classes));
     }
     // if link not empty - wrap image with it
     $link = get_post_meta($post_id, '_dt_logo_options_link', true);
     if ($link) {
         $image_id = dt_is_hd_device() && isset($retina_logo_id[0]) ? $retina_logo_id[0] : $thumb_id;
         $esc_caption = '';
         $attachment = dt_get_attachment($image_id);
         if ($attachment) {
             $esc_caption = esc_attr($attachment['description']);
         }
         $link = esc_attr($link);
         $image = '<a href="' . $link . '" target="_blank" title="' . $esc_caption . '" >' . $image . '</a>';
     }
     // get it all togeather
     return $image;
 }
Exemplo n.º 3
0
 /**
  * This method render's logo item.
  *
  * @param integer $post_id If empty - uses current post id.
  *
  * @return string Item html.
  */
 public static function presscore_render_logo($post_id = null)
 {
     $post_id = $post_id ? $post_id : get_the_ID();
     if (!$post_id) {
         return '';
     }
     $html = '';
     $images = array('normal' => null, 'retina' => null);
     $esc_title = esc_attr(get_the_title());
     // get featured image
     if (has_post_thumbnail($post_id)) {
         $thumb_id = get_post_thumbnail_id($post_id);
         $images['normal'] = wp_get_attachment_image_src($thumb_id, 'full');
     }
     // get retina image
     $retina_logo_id = get_post_meta($post_id, '_dt_logo_options_retina_logo', true);
     if ($retina_logo_id) {
         $images['retina'] = dt_get_uploaded_logo(array('', $retina_logo_id[0]), 'retina');
     }
     // default image
     $default_img = null;
     foreach ($images as $image) {
         if ($image) {
             $default_img = $image;
             break;
         }
     }
     if (!$default_img) {
         return '';
     }
     // final image
     if (presscore_is_srcset_based_retina()) {
         $image = presscore_get_image_with_srcset($images['normal'], $images['retina'], $default_img, 'alt="' . $esc_title . '"');
     } else {
         $image = dt_get_retina_sensible_image($images['normal'], $images['retina'], $default_img, 'alt="' . $esc_title . '"');
     }
     // if link not empty - wrap image with it
     $link = get_post_meta($post_id, '_dt_logo_options_link', true);
     if ($link) {
         $link = esc_attr($link);
         $image = '<a href="' . $link . '" target="_blank" title="' . $esc_title . '" >' . $image . '</a>';
     }
     // get it all togeather
     return $image;
 }