Handle large filepicker URLs in image replacer
authorChristian Weiske <cweiske@cweiske.de>
Fri, 15 Nov 2019 06:32:38 +0000 (07:32 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 15 Nov 2019 06:35:59 +0000 (07:35 +0100)
bin/replace-game-images-by-list

index 223e3985fba671c436c5e70e5bd3104eede207b7..74df284e12ae9ae3e0e06c73934175de3540f639 100755 (executable)
@@ -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];
     }