コード例 #1
0
ファイル: logos.php プロジェクト: noman90rauf/wp-content
 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;
 }
コード例 #2
0
ファイル: functions.php プロジェクト: scottnkerr/eeco
 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 (isset($attributes['animation']) && 'none' != $attributes['animation']) {
         switch ($attributes['animation']) {
             case 'scale':
                 $image_classes[] = 'scale-up';
                 break;
             case 'fade':
                 $image_classes[] = 'fade-in';
                 break;
             case 'left':
                 $image_classes[] = 'right-to-left';
                 break;
             case 'right':
                 $image_classes[] = 'left-to-right';
                 break;
             case 'bottom':
                 $image_classes[] = 'top-to-bottom';
                 break;
             case 'top':
                 $image_classes[] = 'bottom-to-top';
                 break;
         }
         $image_classes[] = 'animate-element';
     }
     // ninjaaaa!
     $image_classes = implode(' ', $image_classes);
     // final image
     $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;
 }