Пример #1
0
 function et_is_portrait($imageurl, $post = '', $ignore_cfields = false)
 {
     if ($post == '') {
         global $post;
     }
     if (get_post_meta($post->ID, 'et_disable_portrait', true) == 1) {
         return false;
     }
     if (!$ignore_cfields) {
         if (get_post_meta($post->ID, 'et_imagetype', true) == 'l') {
             return false;
         }
         if (get_post_meta($post->ID, 'et_imagetype', true) == 'p') {
             return true;
         }
     }
     $imageurl = et_path_reltoabs(et_multisite_thumbnail($imageurl));
     $et_thumb_size = @getimagesize($imageurl);
     if (empty($et_thumb_size)) {
         $et_thumb_size = @getimagesize(str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $imageurl));
         if (empty($et_thumb_size)) {
             return false;
         }
     }
     $et_thumb_width = $et_thumb_size[0];
     $et_thumb_height = $et_thumb_size[1];
     $result = $et_thumb_width < $et_thumb_height ? true : false;
     return $result;
 }
Пример #2
0
 function get_thumbnail($width = 100, $height = 100, $class = '', $alttext = '', $titletext = '', $fullpath = false, $custom_field = '', $post = '')
 {
     if ($post == '') {
         global $post;
     }
     global $shortname;
     $thumb_array['thumb'] = '';
     $thumb_array['use_timthumb'] = true;
     if ($fullpath) {
         $thumb_array['fullpath'] = '';
     }
     //full image url for lightbox
     $new_method = true;
     if (has_post_thumbnail($post->ID)) {
         $thumb_array['use_timthumb'] = false;
         $et_fullpath = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
         $thumb_array['fullpath'] = $et_fullpath[0];
         $thumb_array['thumb'] = $thumb_array['fullpath'];
     }
     if ($thumb_array['thumb'] == '') {
         if ($custom_field == '') {
             $thumb_array['thumb'] = esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true));
         } else {
             $thumb_array['thumb'] = esc_attr(get_post_meta($post->ID, $custom_field, $single = true));
             if ($thumb_array['thumb'] == '') {
                 $thumb_array['thumb'] = esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true));
             }
         }
         #if custom field used for small pre-cropped image, open Thumbnail custom field image in lightbox
         if ($fullpath) {
             $thumb_array['fullpath'] = $thumb_array['thumb'];
             if ($custom_field == '') {
                 $thumb_array['fullpath'] = apply_filters('et_fullpath', et_path_reltoabs(esc_attr($thumb_array['thumb'])));
             } elseif ($custom_field != '' && get_post_meta($post->ID, 'Thumbnail', $single = true)) {
                 $thumb_array['fullpath'] = apply_filters('et_fullpath', et_path_reltoabs(esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true))));
             }
         }
     }
     return $thumb_array;
 }