Skip to content

Commit 591ceb9

Browse files
author
Mark Randall
committed
Better missing logo handling
1 parent f3c8d86 commit 591ceb9

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

index.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ function drawBranchInfo(PointReleaseData $release): void
270270
<div class="landing-lrv-inner-padding" >
271271
<div class="landing-lrv-inner">
272272
<div>
273-
<img src="<?= safe($latestVersion->logoUrl) ?>" alt="php" style="height: 100px; width: 100%; object-fit: contain; margin-left: auto; margin-right: auto">
273+
<?php if ($latestVersion->logoUrl) { ?>
274+
<img src="<?= safe($latestVersion->logoUrl) ?>" alt="php" style="height: 100px; width: 100%; object-fit: contain; margin-left: auto; margin-right: auto">
275+
<?php } ?>
276+
274277
<div style="text-align: center; margin-top: 1em; color: white">
275278
<?php drawBranchInfo($latestVersion->latestRelease) ?>
276279
</div>

releases/8.5/header.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ function drawVersionHeader(VersionData $version, string $title, string $subtitle
99
echo SuperBanner::renderBanner(Util::bufferOutput(function () use ($version, $title, $subtitle) {
1010
?>
1111
<div style="text-align: center; display: flex; flex-direction: column; gap: 1em">
12-
<img src="<?= safe($version->logoUrl) ?>" style="width: 100%; height: 80px; object-fit: contain"/>
12+
<?php if ($version->logoUrl) { ?>
13+
<img alt="Logo for PHP <?= safe($version->label) ?>" src="<?= safe($version->logoUrl) ?>" style="width: 100%; height: 80px; object-fit: contain"/>
14+
<?php } ?>
15+
1316
<div>
1417

1518
<div style="font-size: 35px; margin-top: 1em; font-weight: 500"><?= safe($title) ?></div>

src/Releases/VersionData.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ final class VersionData
5151
private ?DateTimeImmutable $_releaseDate = null;
5252
private ?array $_pointReleases = null;
5353
private ?array $_highlightSnippets = null;
54+
private ?string $_logoCache = null;
5455

5556
public function __construct(public readonly string $label)
5657
{
@@ -242,8 +243,16 @@ public static function all(): array
242243
})();
243244
}
244245

246+
/**
247+
* Returns the current logo url or an empty string
248+
*
249+
* todo: Move these to the data directory
250+
*/
245251
public string $logoUrl {
246-
get => '/images/php8/logo_php' . $this->majorVersion . '_' . $this->minorVersion . '.svg';
252+
get => $this->_logoCache ??= (function() {
253+
$path = '/images/php' . $this->majorVersion . '/logo_php' . $this->majorVersion . '_' . $this->minorVersion . '.svg';
254+
return file_exists(ProjectGlobals::getProjectRoot() . $path) ? $path : null;
255+
})();
247256
}
248257

249258
public ?string $aboutPageURL {

0 commit comments

Comments
 (0)