Skip to content
Snippets Groups Projects
Commit 8ea1367a authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

load images through proxy

parent 9a0de103
Branches
No related tags found
2 merge requests!2246Translated using Weblate (German),!2244Resolve "Rework Startpage"
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
namespace App\Models; namespace App\Models;
use App\Http\Controllers\Pictureproxy;
use Exception;
use Request;
/** /**
* Model to hold data which represents a tile as visible on the startpage * Model to hold data which represents a tile as visible on the startpage
*/ */
...@@ -25,6 +29,13 @@ class Tile implements \JsonSerializable ...@@ -25,6 +29,13 @@ class Tile implements \JsonSerializable
public function __construct(string $title, string $image, string $image_alt, string $url, string $classes = "", string $image_classes = "") public function __construct(string $title, string $image, string $image_alt, string $url, string $classes = "", string $image_classes = "")
{ {
$this->title = $title; $this->title = $title;
try {
$host = parse_url($image, PHP_URL_HOST);
if ($host !== null && Request::host() !== $host) {
$image = Pictureproxy::generateUrl($image);
}
} catch (Exception $e) {
}
$this->image = $image; $this->image = $image;
$this->image_alt = $image_alt; $this->image_alt = $image_alt;
$this->url = $url; $this->url = $url;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
async function fetchAdvertisements() { async function fetchAdvertisements() {
let desired_tile_count = calculateDesiredTileCount(); let desired_tile_count = calculateDesiredTileCount();
let regular_tile_count = getRegularTileCount(); let regular_tile_count = getRegularTileCount();
console.log(desired_tile_count, advertisements.length)
if (advertisements.length >= desired_tile_count - regular_tile_count) return; if (advertisements.length >= desired_tile_count - regular_tile_count) return;
let update_url = document.querySelector("meta[name=tiles-update-url]").content; let update_url = document.querySelector("meta[name=tiles-update-url]").content;
update_url += "&count=" + (desired_tile_count - tile_count); update_url += "&count=" + (desired_tile_count - tile_count);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment