예제 #1
0
 protected function _get_background_attr($is_layout = false, $lazy_loading = false, $breakpoint_id = '')
 {
     $type = $this->get_background_type($breakpoint_id);
     $attr = '';
     $breakpoint = empty($breakpoint_id) ? 'desktop' : $breakpoint_id;
     if (!$type || $type == 'image' || $type == 'featured') {
         if ($type == 'featured' && has_post_thumbnail(Upfront_Output::get_post_id())) {
             $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(Upfront_Output::get_post_id()), 'single-post-thumbnail');
             $background_image = $featured_image[0];
             $background_image_ratio = round($featured_image[2] / $featured_image[1], 2);
         } else {
             $background_image = $this->_get_breakpoint_property('background_image', $breakpoint_id);
             $background_image_ratio = $this->_get_breakpoint_property('background_image_ratio', $breakpoint_id);
         }
         $background_style = $this->_get_breakpoint_property('background_style', $breakpoint_id);
         if ($background_image) {
             if ($lazy_loading) {
                 $attr .= " data-src-{$breakpoint}='{$background_image}'";
             }
             if ($background_style == 'full') {
                 $attr .= " data-bg-image-ratio-{$breakpoint}='{$background_image_ratio}'";
             }
             if (!$type) {
                 $type = 'image';
             }
         }
     }
     if (!$type) {
         $type = 'color';
     }
     $attr .= " data-bg-type-{$breakpoint}='{$type}'";
     return $attr;
 }