예제 #1
0
 public static function filter_disable_wp_responsive_image($args)
 {
     if (PT_CV_Html::is_responsive_image_disabled()) {
         if (isset($args['sizes'])) {
             unset($args['sizes']);
         }
         if (isset($args['srcset'])) {
             unset($args['srcset']);
         }
     }
     return $args;
 }
예제 #2
0
 /**
  * HTML output of thumbnail field
  *
  * @param object $post  The post object
  * @param array  $_fargs The settings of this field
  *
  * @return string
  */
 static function _field_thumbnail($post, $_fargs)
 {
     $layout_format = $_fargs['layout-format'];
     // Get thumbnail settings
     $fargs = $_fargs['thumbnail'];
     // Thumbnail class
     $thumbnail_position = 'default';
     $thumbnail_class = array();
     $thumbnail_class[] = PT_CV_PREFIX . 'thumbnail';
     $thumbnail_class[] = isset($fargs['style']) ? $fargs['style'] : '';
     if ($layout_format === '2-col') {
         $thumbnail_position = isset($fargs['position']) ? $fargs['position'] : 'left';
         $thumbnail_class[] = 'pull-' . $thumbnail_position;
     }
     $gargs = array('class' => apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_class', implode(' ', array_filter($thumbnail_class))));
     /**
      * @since 1.7.5
      * able to disable responsive image of WordPress 4.4
      */
     if (PT_CV_Html::is_responsive_image_disabled()) {
         $gargs['srcset'] = 1;
     }
     // Get thumbnail dimensions
     $dimensions = (array) apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_dimension_output', PT_CV_Functions::field_thumbnail_dimensions($fargs), $fargs);
     // Check if has thumbnail ( has_post_thumbnail doesn't works )
     $thumbnail_id = get_post_thumbnail_id($post->ID);
     $html = '';
     if (!empty($thumbnail_id)) {
         $thumbnail_size = count($dimensions) > 1 ? $dimensions : $dimensions[0];
         $html = wp_get_attachment_image((int) $thumbnail_id, $thumbnail_size, false, $gargs);
         $html = apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_image', $html, $post, $dimensions, $fargs);
     }
     // If no thumbnail
     if (empty($html) || apply_filters(PT_CV_PREFIX_ . 'force_replace_thumbnail', 0)) {
         $html = apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_not_found', $html, $post, $dimensions, $gargs);
     }
     // Maybe add custom wrap for image
     $html = apply_filters(PT_CV_PREFIX_ . 'field_thumbnail_image_html', $html);
     // Add link to thumbnail
     $dargs = PT_CV_Functions::get_global_variable('dargs');
     $oargs = isset($dargs['other-settings']) ? $dargs['other-settings'] : array();
     $html = self::_field_href($oargs, $post, $html, implode(' ', array(PT_CV_PREFIX . 'href-thumbnail', PT_CV_PREFIX . 'thumb-' . $thumbnail_position)));
     return $html;
 }