diff --git a/metager/app/Models/Tile.php b/metager/app/Models/Tile.php index 73e1de114018ee5b4eb1c74c76370b5ba80e60c0..b64ff38b5d094fe58d6638ef8e0e9ec95a208876 100644 --- a/metager/app/Models/Tile.php +++ b/metager/app/Models/Tile.php @@ -2,6 +2,10 @@ 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 */ @@ -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 = "") { $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_alt = $image_alt; $this->url = $url; diff --git a/metager/resources/js/startpage/tiles.js b/metager/resources/js/startpage/tiles.js index 71475b33fb926f025dec63774767a678e5ab87c0..cb6e9fd17643abf8d5ccf316cf2f196b56f6bd7e 100644 --- a/metager/resources/js/startpage/tiles.js +++ b/metager/resources/js/startpage/tiles.js @@ -8,6 +8,7 @@ async function fetchAdvertisements() { let desired_tile_count = calculateDesiredTileCount(); let regular_tile_count = getRegularTileCount(); + console.log(desired_tile_count, advertisements.length) if (advertisements.length >= desired_tile_count - regular_tile_count) return; let update_url = document.querySelector("meta[name=tiles-update-url]").content; update_url += "&count=" + (desired_tile_count - tile_count);