GnoxNahte / obsidian-auto-embed

Obsidian plugin to embed websites using simple markdown instead of iframe
MIT License
18 stars 0 forks source link

Bug report: URL image WITH parameters detected as embed #20

Closed Rikiub closed 8 hours ago

Rikiub commented 9 hours ago

What happened?

Sometimes when I paste a image, instead of be embedded like Obsidian, it's embedded as a "Auto-embed".

Sample Markdown

Detected as embeddable:

Because of content after ? which is t=1721834594.

Fixed:

Errors

No response

Obsidian Version

1.7.2

Plugin Version

1.2.3

OS

Linux

GnoxNahte commented 7 hours ago

Hi, thanks for reporting the bug!

I've made a quick fix that should detect links like the ones that you posted and ignore those.

However, there are some image links that won't work. For example, this is the GitHub link to the image in the issue.

https://camo.githubusercontent.com/25b302c27599e45d1108b7199eb085c91c7dad46eadd3117616ed97dbe4e1d90/68747470733a2f2f7368617265642e636c6f7564666c6172652e737465616d7374617469632e636f6d2f73746f72655f6974656d5f6173736574732f737465616d2f617070732f313831373233302f6865616465722e6a7067

Since it doesn't have the image extension, the plugin can't detect if it's an image and will try to embed it. The plugin does try to request the content type from the image hosting server, which is usually quite fast but it'll take at least 1 frame. In that 1 frame, the auto-embed box will show up and then hide in the next frame. It should've done this check even before this update though. So if it doesn't, let me know.

Not sure why in that 1 frame, it'll delete any new lines after the markdown link... The plugin doesn't have any code that changes content in the file (other than the embed commands).

If this ever happens to you, the best way to solve it is to add noembed inside the square brackets to tell the plugin not to embed it. Example:

![noembed](url)