| @@ 175-213 (lines=39) @@ | ||
| 172 | * This is based on code found in the culturefeed theme. |
|
| 173 | * @see https://github.com/cultuurnet/culturefeed/blob/master/culturefeed_agenda/theme/theme.inc#L266-L284 |
|
| 174 | */ |
|
| 175 | private function importPicture($detail, $jsonLD) |
|
| 176 | { |
|
| 177 | $mainPicture = null; |
|
| 178 | ||
| 179 | // first check if there is a media file that is main and has the PHOTO media type |
|
| 180 | $photos = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO); |
|
| 181 | foreach ($photos as $photo) { |
|
| 182 | if ($photo->isMain()) { |
|
| 183 | $mainPicture = $photo; |
|
| 184 | } |
|
| 185 | } |
|
| 186 | ||
| 187 | // the IMAGEWEB media type is deprecated but can still be used as a main image if there is no PHOTO |
|
| 188 | if (empty($mainPicture)) { |
|
| 189 | $images = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB); |
|
| 190 | foreach ($images as $image) { |
|
| 191 | if ($image->isMain()) { |
|
| 192 | $mainPicture = $image; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | } |
|
| 196 | ||
| 197 | // if there is no explicit main image we just use the oldest picture of any type |
|
| 198 | if (empty($mainPicture)) { |
|
| 199 | $pictures = $detail->getMedia()->byMediaTypes( |
|
| 200 | [ |
|
| 201 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO, |
|
| 202 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB |
|
| 203 | ] |
|
| 204 | ); |
|
| 205 | ||
| 206 | $pictures->rewind(); |
|
| 207 | $mainPicture = count($pictures) > 0 ? $pictures->current() : null; |
|
| 208 | } |
|
| 209 | ||
| 210 | if ($mainPicture) { |
|
| 211 | $jsonLD->image = $mainPicture->getHLink(); |
|
| 212 | } |
|
| 213 | } |
|
| 214 | } |
|
| 215 | ||
| @@ 206-244 (lines=39) @@ | ||
| 203 | * This is based on code found in the culturefeed theme. |
|
| 204 | * @see https://github.com/cultuurnet/culturefeed/blob/master/culturefeed_agenda/theme/theme.inc#L266-L284 |
|
| 205 | */ |
|
| 206 | private function importPicture($detail, $jsonLD) |
|
| 207 | { |
|
| 208 | $mainPicture = null; |
|
| 209 | ||
| 210 | // first check if there is a media file that is main and has the PHOTO media type |
|
| 211 | $photos = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO); |
|
| 212 | foreach ($photos as $photo) { |
|
| 213 | if ($photo->isMain()) { |
|
| 214 | $mainPicture = $photo; |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||
| 218 | // the IMAGEWEB media type is deprecated but can still be used as a main image if there is no PHOTO |
|
| 219 | if (empty($mainPicture)) { |
|
| 220 | $images = $detail->getMedia()->byMediaType(CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB); |
|
| 221 | foreach ($images as $image) { |
|
| 222 | if ($image->isMain()) { |
|
| 223 | $mainPicture = $image; |
|
| 224 | } |
|
| 225 | } |
|
| 226 | } |
|
| 227 | ||
| 228 | // if there is no explicit main image we just use the oldest picture of any type |
|
| 229 | if (empty($mainPicture)) { |
|
| 230 | $pictures = $detail->getMedia()->byMediaTypes( |
|
| 231 | [ |
|
| 232 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_PHOTO, |
|
| 233 | CultureFeed_Cdb_Data_File::MEDIA_TYPE_IMAGEWEB |
|
| 234 | ] |
|
| 235 | ); |
|
| 236 | ||
| 237 | $pictures->rewind(); |
|
| 238 | $mainPicture = count($pictures) > 0 ? $pictures->current() : null; |
|
| 239 | } |
|
| 240 | ||
| 241 | if ($mainPicture) { |
|
| 242 | $jsonLD->image = $mainPicture->getHLink(); |
|
| 243 | } |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * @param \CultureFeed_Cdb_Item_Event $event |
|