Jump to content

Include cover and logo in image gallery


Alejandro

Recommended Posts

By default when you assign a photo to be the cover or logo for a listing, that photo is no longer included in the photo gallery. Using the filter hook below you can re-add those images back to the gallery so they are also shown there.

Clickfwd\Hook\Filter::add('post_get_listing_detailpage_query', function($listing, $params) 
{
  foreach (['Cover', 'Logo'] as $function) {

    if (!isset($listing[$function])) continue;

    if ($listing[$function]['main_media']) {
       unset($listing['MainMedia']);
    }

    $listing['Media']['photo'][] = $listing[$function];
  }

  return $listing;
    
});

There's a bit of extra code there to ensure that if the photo is not only a cover or a logo, but also the main media, it also shows in the gallery in the detail page.

  • Like 3
Link to comment
×
×
  • Create New...