| @@ 171-209 (lines=39) @@ | ||
| 168 | * This is based on code found in the culturefeed theme. |
|
| 169 | * @see https://github.com/cultuurnet/culturefeed/blob/master/culturefeed_agenda/theme/theme.inc#L266-L284 |
|
| 170 | */ |
|
| 171 | private function importPicture($detail, $jsonLD) |
|
| 172 | { |
|
| 173 | $mainPicture = null; |
|
| 174 | ||
| 175 | // first check if there is a media file that is main and has the PHOTO media type |
|
| 176 | $photos = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO); |
|
| 177 | foreach ($photos as $photo) { |
|
| 178 | if ($photo->isMain()) { |
|
| 179 | $mainPicture = $photo; |
|
| 180 | } |
|
| 181 | } |
|
| 182 | ||
| 183 | // the IMAGEWEB media type is deprecated but can still be used as a main image if there is no PHOTO |
|
| 184 | if (empty($mainPicture)) { |
|
| 185 | $images = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB); |
|
| 186 | foreach ($images as $image) { |
|
| 187 | if ($image->isMain()) { |
|
| 188 | $mainPicture = $image; |
|
| 189 | } |
|
| 190 | } |
|
| 191 | } |
|
| 192 | ||
| 193 | // if there is no explicit main image we just use the oldest picture of any type |
|
| 194 | if (empty($mainPicture)) { |
|
| 195 | $pictures = $detail->getMedia()->byMediaTypes( |
|
| 196 | [ |
|
| 197 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO, |
|
| 198 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB |
|
| 199 | ] |
|
| 200 | ); |
|
| 201 | ||
| 202 | $pictures->rewind(); |
|
| 203 | $mainPicture = count($pictures) > 0 ? $pictures->current() : null; |
|
| 204 | } |
|
| 205 | ||
| 206 | if ($mainPicture) { |
|
| 207 | $jsonLD->image = $mainPicture->getHLink(); |
|
| 208 | } |
|
| 209 | } |
|
| 210 | } |
|
| 211 | ||
| @@ 262-300 (lines=39) @@ | ||
| 259 | * This is based on code found in the culturefeed theme. |
|
| 260 | * @see https://github.com/cultuurnet/culturefeed/blob/master/culturefeed_agenda/theme/theme.inc#L266-L284 |
|
| 261 | */ |
|
| 262 | private function importPicture($detail, $jsonLD) |
|
| 263 | { |
|
| 264 | $mainPicture = null; |
|
| 265 | ||
| 266 | // first check if there is a media file that is main and has the PHOTO media type |
|
| 267 | $photos = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO); |
|
| 268 | foreach ($photos as $photo) { |
|
| 269 | if ($photo->isMain()) { |
|
| 270 | $mainPicture = $photo; |
|
| 271 | } |
|
| 272 | } |
|
| 273 | ||
| 274 | // the IMAGEWEB media type is deprecated but can still be used as a main image if there is no PHOTO |
|
| 275 | if (empty($mainPicture)) { |
|
| 276 | $images = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB); |
|
| 277 | foreach ($images as $image) { |
|
| 278 | if ($image->isMain()) { |
|
| 279 | $mainPicture = $image; |
|
| 280 | } |
|
| 281 | } |
|
| 282 | } |
|
| 283 | ||
| 284 | // if there is no explicit main image we just use the oldest picture of any type |
|
| 285 | if (empty($mainPicture)) { |
|
| 286 | $pictures = $detail->getMedia()->byMediaTypes( |
|
| 287 | [ |
|
| 288 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO, |
|
| 289 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB |
|
| 290 | ] |
|
| 291 | ); |
|
| 292 | ||
| 293 | $pictures->rewind(); |
|
| 294 | $mainPicture = count($pictures) > 0 ? $pictures->current() : null; |
|
| 295 | } |
|
| 296 | ||
| 297 | if ($mainPicture) { |
|
| 298 | $jsonLD->image = $mainPicture->getHLink(); |
|
| 299 | } |
|
| 300 | } |
|
| 301 | ||
| 302 | /** |
|
| 303 | * @param \CultureFeed_Cdb_Item_Event $event |
|