Show images in banner custom fields
- Thread started
- Last updated
What you’ll achieve
Display clickable images in a banner custom field, including links to the listing owner's EasySocial sections.
My site
Display linked images in a banner custom field, including a six-image banner leading to the listing owner's EasySocial sections. Adapt and check the image paths and EasySocial destinations for your Joomla site.
Prepare the images and EasySocial sections
This guide requires Joomla and EasySocial. Upload your images to /media/hotlinks. Enable the EasySocial sections you want to link. Create a listing custom field with type Banner and choose a listing field group in the field editor. In each listing type where the images should appear, include that group in Field Groups. You can reuse an existing associated group. Enable the banner in the required display locations. Check the route parameters against your installed EasySocial release; the examples target EasySocial 5.1.1.
JReviews 6 Early Access
Add the linked images
In Configuration > Early Access Settings, enable Listing Detail Page to show this banner on listing detail pages. If you also show it on list pages, enable Listing List Pages.
Edit the banner custom field. In Advanced Settings > Blade template code, paste this template. Replace the image filenames with your own. Keep only the EasySocial features you have enabled. Remove the other entries from $items; a disabled feature can redirect visitors or return a 404 page.
@php
$ownerId = (int) $listing->owner_id;
$items = [
['view' => 'albums', 'query' => ['type' => 'user', 'uid' => $ownerId], 'image' => 'myphotos.png', 'label' => 'Photos'],
['view' => 'videos', 'query' => ['type' => 'user', 'uid' => $ownerId], 'image' => 'myvideos.png', 'label' => 'Videos'],
['view' => 'audios', 'query' => ['type' => 'user', 'uid' => $ownerId], 'image' => 'myaudios.png', 'label' => 'Audio'],
['view' => 'events', 'query' => ['userid' => $ownerId], 'image' => 'myevents.png', 'label' => 'Events'],
['view' => 'marketplaces', 'query' => ['type' => 'user', 'uid' => $ownerId], 'image' => 'mymarketplace.png', 'label' => 'Marketplace'],
['view' => 'groups', 'query' => ['userid' => $ownerId], 'image' => 'mygroups.png', 'label' => 'Groups'],
];
@endphp
@if ($ownerId > 0)
<div style="display:flex;flex-wrap:wrap;gap:8px">
@foreach ($items as $item)
@php
$url = \Joomla\CMS\Router\Route::_('index.php?option=com_easysocial&' . http_build_query(['view' => $item['view']] + $item['query']));
@endphp
<a href="{{ $url }}"><img src="{{ '/media/hotlinks/' . $item['image'] }}" alt="{{ $item['label'] }}" width="90" style="width:90px;display:block"></a>
@endforeach
</div>
@endif
The links target the listing owner. EasySocial decides whether the visitor may see that owner's content.
For one image, leave one entry in $items. For three images, keep three entries. Change width="90" and width:90px together to resize the images. The flex layout keeps the images beside one another while space permits and wraps them on narrow screens.
JReviews 5 and v6 Legacy
Return the complete banner
Paste the complete code below into the banner field's PHP output setting, without an opening PHP tag. It creates six links with 90-pixel-wide images. Keep the final return $banner; line after all six image lines.
$photoLink = cmsFramework::route("index.php?option=com_easysocial&view=albums&type=user&uid={$listing['User']['user_id']}");
$videoLink = cmsFramework::route("index.php?option=com_easysocial&view=videos&type=user&uid={$listing['User']['user_id']}");
$eventLink = cmsFramework::route("index.php?option=com_easysocial&view=events&userid={$listing['User']['user_id']}");
$marketplaceLink = cmsFramework::route("index.php?option=com_easysocial&view=marketplaces&type=user&uid={$listing['User']['user_id']}");
$groupLink = cmsFramework::route("index.php?option=com_easysocial&view=groups&userid={$listing['User']['user_id']}");
$audioLink = cmsFramework::route("index.php?option=com_easysocial&view=audios&type=user&uid={$listing['User']['user_id']}");
$banner = "<a href='{$photoLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/myphotos.png' /></a>";
$banner .= "<a href='{$videoLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/myvideos.png' /></a>";
$banner .= "<a href='{$audioLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/mypodcasts.png' /></a>";
$banner .= "<a href='{$eventLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/myevents.png' /></a>";
$banner .= "<a href='{$marketplaceLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/myoffers.png' /></a>";
$banner .= "<a href='{$groupLink}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/mygroups.png' /></a>";
return $banner;
Change the image paths and destinations for your site. Set a Joomla menu item ID only if your routing requires one. The images must exist at the paths you use. Add another link using the same pattern if you need more than six.
These routes target EasySocial 5.1.1 on Joomla. Photos opens the listing owner's albums. Videos, audios, and marketplace listings identify the owner with uid and type=user; groups and events use userid. The examples leave out Itemid so routing can select an appropriate menu item. If your site needs a particular menu item, use its real ID. EasySocial privacy rules still apply.
Display a single linked image
For a single image, put the complete image path inside quotes and use forward slashes, as shown below.
$photoLink = cmsFramework::route("index.php?option=com_easysocial&view=albums&type=user&uid={$listing['User']['user_id']}");
echo "<a href='{$photoLink}'><img src='/media/hotlinks/homelogo.jpg' /></a>";
Use this complete example only for one image. For several images, use the six-image or three-image example, which returns all links together.
Assemble a smaller banner
For three images, use the same pattern: build the link HTML and return the complete string. Replace the example destinations as needed.
$link1 = cmsFramework::route("index.php?option=com_easysocial&view=albums&type=user&uid={$listing['User']['user_id']}");
$link2 = cmsFramework::route("index.php?option=com_easysocial&view=albums&type=user&uid={$listing['User']['user_id']}");
$link3 = cmsFramework::route("index.php?option=com_easysocial&view=albums&type=user&uid={$listing['User']['user_id']}");
$banner = '';
$banner .= "<a href='{$link1}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/homelogo.jpg' /></a>";
$banner .= "<a href='{$link2}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/homelogo.jpg' /></a>";
$banner .= "<a href='{$link3}'><img style='width: 90px; display:inline-block;' src='/media/hotlinks/homelogo.jpg' /></a>";
return $banner;
The fixed width and inline-block styles control the image sizing and inline layout. They do not guarantee that all images fit on one row on a small screen. Check the result at the widths used by your site.
These PHP examples require Joomla and EasySocial and read the owner of the listing being displayed.
Check each image and destination
Display listings owned by two different users. Confirm the images load and each link opens the correct owner section. Repeat as a signed-in visitor and as a guest. Confirm EasySocial privacy rules still apply. Check the banner at narrow screen widths; fixed image widths do not guarantee a single row.