- Fixed the Imgur embed path.
Imgur now uses a local wrapper page, [provider_embed.php](/Users/tyemeclifford/Documents/GH/mediaplayer/provider_embed.php), that renders Imgur’s official blockquote + https://s.imgur.com/min/embed.js snippet instead of trying to iframe Imgur directly. That should avoid the “refuses to connect” issue for albums, galleries, images, GIFs, GIFV, and videos. Also updated: [includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php): Imgur embed URLs now point to the wrapper, and Imgur view-count scraping has dedicated fallback patterns. [admin/index.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/index.php): Upkeeping → Correct Views now explicitly counts Imgur-backed items in the candidate summary. [README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md): documented the Imgur wrapper behavior.
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/db.php';
|
||||
|
||||
$provider = strtolower(trim((string)($_GET['provider'] ?? '')));
|
||||
$id = trim((string)($_GET['id'] ?? ''));
|
||||
|
||||
if ($provider !== 'imgur') {
|
||||
http_response_code(404);
|
||||
exit('Unsupported provider.');
|
||||
}
|
||||
|
||||
$parts = array_values(array_filter(explode('/', $id), 'strlen'));
|
||||
$data_id = '';
|
||||
if (isset($parts[0], $parts[1]) && in_array($parts[0], ['a', 'gallery'], true)) {
|
||||
$clean = media_clean_token($parts[1]);
|
||||
if ($clean !== '') $data_id = $parts[0] . '/' . $clean;
|
||||
} elseif (isset($parts[0])) {
|
||||
$clean = media_clean_token($parts[0]);
|
||||
if ($clean !== '') $data_id = $clean;
|
||||
}
|
||||
|
||||
if ($data_id === '') {
|
||||
http_response_code(400);
|
||||
exit('Invalid Imgur item.');
|
||||
}
|
||||
|
||||
$imgur_url = 'https://imgur.com/' . $data_id;
|
||||
$title = 'Imgur media';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer-when-downgrade">
|
||||
<title><?= h($title) ?></title>
|
||||
<style>
|
||||
html, body {
|
||||
margin:0;
|
||||
width:100%;
|
||||
min-height:100%;
|
||||
background:#000;
|
||||
color:#fff;
|
||||
font-family:Inter, system-ui, sans-serif;
|
||||
}
|
||||
body {
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
overflow:auto;
|
||||
}
|
||||
.imgur-embed-pub {
|
||||
width:100%;
|
||||
max-width:100%;
|
||||
margin:0 auto !important;
|
||||
}
|
||||
.imgur-embed-pub iframe {
|
||||
max-width:100% !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<blockquote class="imgur-embed-pub" lang="en" data-id="<?= h($data_id) ?>">
|
||||
<a href="<?= h($imgur_url) ?>" target="_blank" rel="noopener">View on Imgur</a>
|
||||
</blockquote>
|
||||
<script async src="https://s.imgur.com/min/embed.js" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user