[openstreetmap/openstreetmap-website] Image download with user feedback (PR #6192)

Marwin Hochfelsner notifications at github.com
Sat Jul 19 13:15:18 UTC 2025


@hlfan commented on this pull request.



> +          const contentType = blob.type;
+          let extension = "bin";
+          if (contentType === "image/png") extension = "png";
+          else if (contentType === "image/jpeg") extension = "jpg";
+          else if (contentType === "image/svg+xml") extension = "svg";
+          else if (contentType === "image/webp") extension = "webp";
+          else if (contentType === "application/pdf") extension = "pdf";
+          a.download = `map.${extension}`;

Without a value in the download attribute, the browser will decide filename and extension from the blob type for object URLs ([MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#download)), but with `download="map"` set the extension should still be determined from the `blob.type`.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6192#discussion_r2217316015
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6192/review/3035371194 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250719/b02e1ee8/attachment.htm>


More information about the rails-dev mailing list