Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
71
app/Support/Health/Checks/ImagesWithoutAlt.php
Normal file
71
app/Support/Health/Checks/ImagesWithoutAlt.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Support\Health\Checks;
|
||||
|
||||
use App\Models\ImageAttachment;
|
||||
use App\Models\Page;
|
||||
use App\Models\Project;
|
||||
use App\Support\Health\Check;
|
||||
use App\Support\Health\Finding;
|
||||
|
||||
/**
|
||||
* Images on the public site that nobody described.
|
||||
*
|
||||
* An image with no alt text is invisible to anyone using a screen reader, and
|
||||
* to everybody when it fails to load. The API sends `alt: ""` in that case,
|
||||
* which is the correct way to say "decorative" — so the frontend cannot tell
|
||||
* a deliberate blank from a forgotten one. This can.
|
||||
*
|
||||
* Avatars are not counted: their description is the person's name, and the
|
||||
* panel fills that in itself.
|
||||
*/
|
||||
class ImagesWithoutAlt implements Check
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'images-without-alt';
|
||||
}
|
||||
|
||||
public function permission(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function run(): Finding
|
||||
{
|
||||
$default = (string) config('locales.default');
|
||||
$count = 0;
|
||||
$samples = [];
|
||||
|
||||
foreach (Project::query()->published()->whereNotNull('cover_image')->get(['id', 'title', 'cover_image', 'cover_image_alt']) as $project) {
|
||||
if (filled($project->getTranslation('cover_image_alt', $default, false))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count++;
|
||||
$samples[] = $project->getTranslation('title', $default, false);
|
||||
}
|
||||
|
||||
foreach (Page::query()->published()->whereNotNull('featured_image')->get(['id', 'title', 'featured_image', 'featured_image_alt']) as $page) {
|
||||
if (filled($page->getTranslation('featured_image_alt', $default, false))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count++;
|
||||
$samples[] = $page->getTranslation('title', $default, false);
|
||||
}
|
||||
|
||||
foreach (ImageAttachment::query()->with('attachable')->get(['id', 'attachable_type', 'attachable_id', 'alt']) as $image) {
|
||||
if (filled($image->getTranslation('alt', $default, false))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count++;
|
||||
$samples[] = __('health.bits.gallery_image');
|
||||
}
|
||||
|
||||
return Finding::problem($this->key(), $count, samples: array_values(array_unique($samples)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user