# 带查询字符串的图片链接会导致奇怪的文件名字幕

**URL:** https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866
**Category:** Feature
**Created:** [2014年六月25日 16:22 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866 "2014-06-25T16:22:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![samluescher](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@samluescher](https://meta.discourse.org/u/samluescher)
#### Post date: [2014年六月25日 16:22 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/1 "2014-06-25T16:22:40Z")

</div>

Embedding images with links containing a query string, e.g. [foo.com/attachments/token/sc1kod6qalzegkg/?name=sunset.jpg](http://foo.com/attachments/token/sc1kod6qalzegkg/?name=sunset.jpg)  
results in weird-looking filename caption “?name=sunset.jpg”.

Maybe check for query string?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2014年六月25日 17:07 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/2 "2014-06-25T17:07:06Z")

</div>

Do you have an actual example I can check?

---

<div class="post-metadata">

### Author: ![samluescher](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@samluescher](https://meta.discourse.org/u/samluescher)
#### Post date: [2014年七月9日 17:16 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/3 "2014-07-09T17:16:18Z")

</div>

It happens with img tags, for instance:

```
<img src="https://support.formlabs.com/attachments/token/8Arjif5NfwPnqcGgGD9LHBKn8/?name=P1020315_s.jpg">

```

 ![](https://global.discourse-cdn.com/meta/original/3X/b/a/ba54d546e0d8b9a603553165ae2ae832fcbea82c.png)

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [2014年七月9日 17:38 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/4 "2014-07-09T17:38:42Z")

</div>

A generic fix would be to have the composer generate an `alt` property from the URL and change the lightbox to display that value as the image title instead – allowing users to enter a filename or description manually, if so desired.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2014年七月9日 23:02 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/5 "2014-07-09T23:02:01Z")

</div>

We could try to regex out a filename, but that might be error prone too. At least the filename is in the querystring, so it is fairly clear what it is:

`?name=P1020315_s.jpg`

---

<div class="post-metadata">

### Author: ![manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/manuel/32/468169_2.png) [@manuel](https://meta.discourse.org/u/manuel)
#### Post date: [2024年八月26日 17:24 UTC](https://meta.discourse.org/t/image-links-with-query-string-results-in-weird-looking-filename-caption/16866/6 "2024-08-26T17:24:32Z")

</div>

由于这会很好地包含在图注中，例如，对于 Unsplash 图片，因此重新提出此问题。

在预览中看起来不错：

 ![Screenshot from 2024-08-26 18-20-01](https://global.discourse-cdn.com/meta/original/4X/3/d/e/3deb48a88ffe51c28b669a4ab8bb94356f255879.jpeg)

但悬停时链接未解析：

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/4/e/54e3e30cd3ee59e13dcfe05b6f4f71dd1cc7752b.jpeg)
