Пример #1
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) && !('' != $custom_field && get_post_meta($post->ID, $custom_field, true))) {
         $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 ($thumb_array['thumb'] == '' && et_get_option($shortname . '_grab_image') == 'on') {
             $thumb_array['thumb'] = esc_attr(et_first_image());
             if ($fullpath) {
                 $thumb_array['fullpath'] = $thumb_array['thumb'];
             }
         }
         #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;
 }
 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) && !('' != $custom_field && get_post_meta($post->ID, $custom_field, true))) {
         $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];
         $args = '';
         if ($class != '') {
             $args['class'] = $class;
         }
         if ($alttext != '') {
             $args['alt'] = $alttext;
         }
         if ($titletext != '') {
             $args['title'] = $titletext;
         }
         if ($new_method) {
             $et_crop = get_post_meta($post->ID, 'et_nocrop', true) == '' ? true : false;
             $new_method_thumb = et_resize_image($thumb_array['fullpath'], $width, $height, $et_crop);
             if (!is_wp_error($new_method_thumb)) {
                 $attributes = '';
                 if (!empty($args)) {
                     foreach ($args as $key => $attribute) {
                         $attributes .= ' ' . $key . '="' . $attribute . '"';
                     }
                 }
                 $thumb_array['thumb'] = '<img src="' . $new_method_thumb . '" ' . $attributes . ' />';
             }
         }
     }
     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 ($thumb_array['thumb'] == '' && get_option($shortname . '_grab_image') == 'on') {
             $thumb_array['thumb'] = esc_attr(et_first_image());
             if ($fullpath) {
                 $thumb_array['fullpath'] = $thumb_array['thumb'];
             }
         }
         #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;
 }