From 98fbf1b6f22a862bce59813007139f12f1078e14 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 15 Nov 2019 07:32:38 +0100 Subject: [PATCH] Handle large filepicker URLs in image replacer --- bin/replace-game-images-by-list | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/replace-game-images-by-list b/bin/replace-game-images-by-list index 223e398..74df284 100755 --- a/bin/replace-game-images-by-list +++ b/bin/replace-game-images-by-list @@ -52,6 +52,19 @@ foreach ($files as $file) { function replaceImage(&$url) { global $mapping; + + preg_match('#https://www.filepicker.io/api/file/([^/]+)/convert\?w=720#', $url, $matches); + if (isset($matches[1])) { + $url = 'https://d3e4aumcqn8cw3.cloudfront.net/api/file/' . $matches[1]; + } + + if (strlen($url) == 55) { + preg_match('#https://www.filepicker.io/api/file/([^/]+)$#', $url, $matches); + if (isset($matches[1])) { + $url = 'https://d3e4aumcqn8cw3.cloudfront.net/api/file/' . $matches[1]; + } + } + if (isset($mapping[$url])) { $url = $mapping[$url]; } -- 2.30.2