JReviews logo
Guides My site

Show listing photos on My Reviews

Alejandro
Contributors Alejandro.
Started
Last updated

What you’ll achieve

Show each listing's main photo instead of the reviewer avatar on My Reviews, while keeping the reviewer name and profile link.

My site

Platform
JReviews version

Show the reviewed listing's main photo beside each review on My Reviews. For an album directory, each review shows the album artwork. The reviewer name stays, with its profile link if your site links reviewer names to profiles. Reviews without an available main photo keep the reviewer avatar. Latest User Reviews keeps its existing avatars.

Prepare the listings and My Reviews page

Use your site's My Reviews page, where a signed-in user sees the reviews they wrote. It shows nothing to visitors who are not signed in, so sign in on the site as a user who has reviewed several listings. Each listing needs a published, approved main photo that the viewing account can access. For example, give the Blue Horizon album listing its album artwork as the main photo. A review of Blue Horizon then shows that artwork.

This example uses the listing's main photo. A separate header cover image does not replace it. It applies to standard JReviews listings.

Back up any override files you already use. Create missing folders in the paths below. All paths start at your CMS site root. Add the customization once, and merge it into existing overrides so that you keep earlier changes.

For a new PHP hook file, keep <?php on the first line and add defined('MVC_FRAMEWORK') or die; immediately after it. For an existing PHP file, append the callback inside PHP without repeating the opening tag or guard. Keep the file's existing code.

JReviews 6 Early Access

Open the JReviews dashboard and select Manage Early Access. In the Early Access Settings panel, turn on Comments/Reviews List Page if it is off. Complete both steps below.

Add the My Reviews hook

Open or create this file:

Use templates/jreviews_overrides/hooks.php.

Use jreviews_overrides/hooks.php.

Add the callback marked with +. It selects the listing photos for My Reviews and keeps that selection when a visitor changes the sort order or page.

  • If hooks.php already exists, add the marked lines at the end of the file. The copy button copies only those lines.
  • If you are creating hooks.php, type the two dimmed lines first, then add the marked lines below them.
<?php
defined('MVC_FRAMEWORK') or die;

fwd_add_filter('jreviews:view_data:comment_comments_list', function ($data) {
    if (!filter_var($data['myComments'] ?? false, FILTER_VALIDATE_BOOLEAN)) {
        return $data;
    }
    $comments = $data['comments']->getCollection();
    $levels = (array) (fwd_auth()->user()?->access_levels ?? [1]);
    $comments->load([
        'listing.media' => fn ($query) => $query->published()->whereIn('access', $levels),
    ]);
    foreach ($comments as $comment) {
        $comment->setAttribute('my_reviews_listing_photo', true);
    }
    return $data;
}, 20, 1);

Replace the reviewer image in the template

Copy the installed template to the override path for your CMS. If the override already exists, edit that copy.

Copy components/com_jreviews/resources/views/site/components/comment/comment-detail.blade.php to templates/jreviews_overrides/resources/views/site/components/comment/comment-detail.blade.php.

Copy wp-content/plugins/jreviews/resources/views/site/components/comment/comment-detail.blade.php to jreviews_overrides/resources/views/site/components/comment/comment-detail.blade.php.

Keep the site folder in the override path. In the review header, below the <header line, replace the <x-jreviews::user ... /> block with the new code. In the block below, the lines marked with - are the ones you remove, and the lines marked with + are the ones you add in their place. The dimmed lines stay as they are. The copy button copies only the added lines. Keep the rest of the template.

    <header class="fwd-flex fwd-items-center fwd-gap-3 fwd-flex-wrap">
        <x-jreviews::user
            :user="$comment->user"
            :default-name="$comment->name"
            size="md"
            name-class="fwd-text-sm fwd-font-semibold fwd-text-body"
        />
        @php
            $listing = $comment->listing;
            $photo = ($comment->my_reviews_listing_photo && $listing?->exists)
                ? $listing->mainPhoto
                : null;
            $photoSrc = ($photo?->exists && $photo->media_type === 'photo') ? $photo->small : null;
        @endphp
        @if ($photoSrc)
            <a href="{{ $listing->url }}">
                <img src="{{ $photoSrc }}" alt="{{ $listing->title }}" width="100" height="100"
                     loading="lazy" class="fwd-rounded-md fwd-object-contain">
            </a>
            <x-jreviews::user-link
                :user="$comment->user"
                :default-name="$comment->name"
                class="fwd-text-sm fwd-font-semibold fwd-text-body"
            />
        @else
            <x-jreviews::user
                :user="$comment->user"
                :default-name="$comment->name"
                size="md"
                name-class="fwd-text-sm fwd-font-semibold fwd-text-body"
            />
        @endif

        <span class="fwd-text-tertiary fwd-text-xs">·</span>

The image links to the listing and fits within 100 by 100 pixels without cropping. The reviewer name keeps its profile link, if your site has one. When the main photo is missing, unpublished, unapproved, inaccessible, or not a photo, the original reviewer display appears.

Save both files and reload My Reviews. If your site caches pages, clear that page cache before checking the result.

JReviews 5 and v6 Legacy

This procedure uses the legacy My Reviews page. Complete both steps below.

Keep Comments/Reviews List Page disabled in Early Access for this procedure.

Add the My Reviews filter

Open or create this file:

Use templates/jreviews_overrides/filters/filter_functions.php.

Use jreviews_overrides/filters/filter_functions.php.

Add the callback marked with +. It loads the listing main photos for the reviews on the current page. Existing review attachments remain available.

  • If filter_functions.php already exists, add the marked lines at the end of the file. The copy button copies only those lines.
  • If you are creating filter_functions.php, type the two dimmed lines first, then add the marked lines below them.
<?php
defined('MVC_FRAMEWORK') or die;

Clickfwd\Hook\Filter::add('before_theme_render_viewvars_reviews_myreviews', function ($viewVars, $params) {
    $ids = [];
    foreach ($viewVars['reviews'] ?? [] as $review) {
        if (($review['Review']['extension'] ?? '') === 'com_content') {
            $id = (int) $review['Review']['listing_id'];
            if ($id > 0) {
                $ids[$id] = $id;
            }
        }
    }
    if (!$ids) {
        return $viewVars;
    }
    S2App::import('Component', 'listings_repository', 'jreviews');
    $context = (object) ['name' => 'reviews', 'action' => 'myreviews'];
    $repository = (new ListingsRepositoryComponent())->startup($context);
    $listings = $repository->whereListingId(implode(',', $ids))->published()->many();
    $covers = [];
    foreach ($listings as $listing) {
        if (!empty($listing['MainMedia']['media_info']) && ($listing['MainMedia']['media_type'] ?? '') === 'photo') {
            $covers[(int) $listing['Listing']['listing_id']] = $listing['MainMedia'];
        }
    }
    foreach ($viewVars['reviews'] as &$review) {
        if (($review['Review']['extension'] ?? '') === 'com_content') {
            $review['ListingMainMedia'] = $covers[(int) $review['Review']['listing_id']] ?? null;
        }
    }
    unset($review);
    return $viewVars;
});

Replace the avatar in your active custom theme

Open Configuration > Theme & Navigation and note the selected Site Theme. Use that active custom theme for the override. If you use a separate Mobile Theme, apply the same template change to that custom theme as well.

If you have no custom theme, create and select one before continuing:

JReviews 5. Follow Create a custom theme. Keep the default theme as the fallback.

JReviews 6 Legacy. Follow Create a custom theme. Keep the default theme as the fallback.

In the paths below, replace mysite with the folder name of your active custom theme. Do not create an override theme named default.

Copy components/com_jreviews/jreviews/views/themes/default/reviews/review_list_layout.thtml to templates/jreviews_overrides/views/themes/mysite/reviews/review_list_layout.thtml.

Copy wp-content/plugins/jreviews/jreviews/views/themes/default/reviews/review_list_layout.thtml to jreviews_overrides/views/themes/mysite/reviews/review_list_layout.thtml.

If this file already exists in your custom theme, edit that copy. Use Theme Explorer to confirm that My Reviews uses this template if your theme has a different review layout.

Below the line that is exactly <div class="jrUserInfo">, replace the avatar output with the new code. A nearby line, <div class="jrReviewLayoutLeft jrUserInfo">, is a different line. In the block below, the line marked with - is the one you remove, and the lines marked with + are the ones you add in its place. The dimmed lines stay as they are. Keep the reviewer-name output, including $Community->screenName($review).

		<div class="jrUserInfo">

			<?php echo $Community->avatar($review);?>
			<?php if ($this->name === 'reviews' && $this->action === 'myreviews' && !empty($review['ListingMainMedia'])): ?>
				<?php echo $Media->thumb($review['ListingMainMedia'], ['listing' => $listing, 'size' => '100x100', 'mode' => 'scale']); ?>
			<?php else: ?>
				<?php echo $Community->avatar($review); ?>
			<?php endif; ?>

			<div class="jrUserInfoText">

The photo fits within 100 by 100 pixels without cropping. The reviewer name and profile link remain in their original markup. A review without an available listing main photo keeps its avatar.

Save both files. In the JReviews control panel, run Clear Cache & File Registry so that JReviews finds the new override files. Clear your CMS page cache if enabled, then reload My Reviews.

Check the result

  1. Sign in to the account with reviews and open My Reviews. Confirm that each review shows the main photo of its own listing. In the album example, Blue Horizon shows its album artwork.
  2. If reviewer names link to profiles on your site, follow one and confirm that it still opens the reviewer's profile.
  3. Change Sort by if the page offers it, then open another page of reviews. Confirm that each image still matches its listing.
  4. Check a review whose listing has no published main photo. Confirm that the reviewer avatar appears.
  5. Open Latest User Reviews. Confirm that it keeps its reviewer avatars.

Keep your override backups. After a JReviews update, compare each copied template with the new installed original and merge any required template changes.

Learn more