コード例 #1
0
 /**
  * Search the media gallery for suitable images.
  * 
  * This is the order:
  * Check if current post has attached images
  * Check the default language if has attached images
  * Check if frontpage has attached images
  * Check if frontpage has attached images in default language
  * Build a placeholder
  */
 public function get_images()
 {
     $args = array();
     if ($this->image_number) {
         $args['numberposts'] = $this->image_number;
     }
     $this->add_images(self::get_images_from_post($args));
     // = self::get_images_from_post();
     if (!$this->has_images()) {
         $this->add_images(self::get_images_from_main_language($args));
     }
     if (!$this->has_images() && HotelManager::$enabled) {
         $this->add_images(self::get_images_from_closest_hotel($args));
     }
     if (!$this->has_images() && HotelManager::$enabled) {
         $this->add_images(self::get_images_from_closest_hotel_in_default_language($args));
     }
     if (!$this->has_images()) {
         $this->add_images(self::get_images_from_frontpage($args));
     }
     if (!$this->has_images()) {
         $this->add_images(self::get_images_from_homepage_in_default_language($args));
     }
     if (!$this->has_images()) {
         $dimensions = ImageGenerator::get_dimensions($this->media_dimension);
         if ($dimensions['width'] == 'unknown') {
             return $this;
         }
         $image = new ImageGenerator();
         $image->set('width', $dimensions['width'])->set('height', $dimensions['height'])->set('bg_color', 'cccccc')->set('text_color', '222222');
         $this->add_image(array('src' => $image->get_image_src(), 'alt' => $image->get_image_alt(), 'width' => $image->get_image_width(), 'height' => $image->get_image_height()));
     }
     return $this;
 }