# THIS YOU — Reader HERO Gallery Layout API

Portable issue layouts can use the renderer-provided variable:

```php
$readerHeroImages
```

It contains up to 3 distinct already-generated personalized chapter HERO images for the current `user_issue`.

Default preference order:

```text
Chapter 1
Chapter 3
Chapter 6
then any other available chapter HERO
```

Missing preferred chapters are skipped. Duplicate image paths are deduplicated.
No new image is generated. No shared issue image or sponsor image is used as fallback.

Each item:

```php
array(
    'chapter_number' => 1,
    'original_path'  => 'assets/.../hero.jpg',
    'path'           => 'assets/.../hero.jpg', // print may be valid _up2x.jpg
    'url'            => 'http://.../assets/.../hero.jpg',
    'source'         => 'chapter_hero'
)
```

Recommended layout usage:

```php
<?php $heroes = isset($readerHeroImages) && is_array($readerHeroImages) ? $readerHeroImages : array(); ?>

<?php if ($heroes): ?>
  <div class="reader-hero-grid count-<?php echo count($heroes); ?>">
    <?php foreach ($heroes as $hero): ?>
      <figure>
        <img src="<?php echo h($hero['url']); ?>" alt="">
      </figure>
    <?php endforeach; ?>
  </div>
<?php endif; ?>
```

Fallback rule:

- 3 images: render 3
- 2 images: render 2, no duplication
- 1 image: render 1, preferably larger/centered
- 0 images: hide the image block in production; do not show A/B/C or waiting placeholders

Digital/web receives original HERO references.
Print/PDF receives the valid print `_up2x` sibling when available, otherwise the original.

Admin/debug JSON endpoint:

```text
/admin/reader-hero-gallery.php?instance=1
/admin/reader-hero-gallery.php?instance=1&mode=print
/admin/reader-hero-gallery.php?ui=5&limit=3&preferred=1,3,6
```

The endpoint requires admin login. It is for inspection/integration/debugging; layouts should use `$readerHeroImages` directly.
