noatpad/obsidian-banners

[Bug?] Cannot paste image url on v.2.0.0-beta

Closed this issue · 10 comments

Hi, thank you for making this awesome plugin alive again.

I tried v2.0.0-beta, and I copied a URL https://github.com/RyotaUshio/obsidian-math-booster/raw/master/docs/fig/screenshot.png and ran the command Paste banner from clipboard. But it gave me an error "Couldn't load the banner! Is the banner field correct?"

Screen.Recording.2023-09-17.at.4.11.38.mov

Am I doing something dumb or is it a bug? Or is URL not supported yet in v2?

SYSTEM INFO:
	Obsidian version: v1.4.13
	Installer version: v1.4.13
	Operating system: Darwin Kernel Version 22.3.0: Thu Jan  5 20:53:49 PST 2023; root:xnu-8792.81.2~2/RELEASE_X86_64 22.3.0
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: Minimal v7.2.1
	Snippets enabled: 13
	Restricted mode: off
	Plugins installed: 80
	Plugins enabled: 53
		1: Advanced Tables v0.19.1
		2: CSS Editor v0.5.0
		3: Dataview v0.5.58
		4: Obsidian42 - BRAT v0.7.0
		5: Paste URL into selection v1.7.0
		6: Style Settings v1.0.7
		7: Extended MathJax v0.4.1
		8: Minimal Theme Settings v7.2.2
		9: Tasks v4.7.0
		10: Linter v1.20.0
		11: Latex Suite v1.8.1
		12: Quick Latex for Obsidian v2.6.3
		13: Another Quick Switcher v9.1.0
		14: Periodic Notes v0.0.17
		15: Rollover Daily Todos v1.1.7
		16: Calendar v1.5.10
		17: Lapel v0.1.1
		18: Day Planner v0.9.1
		19: Settings Search v1.3.8
		20: QuickAdd v1.2.1
		21: Tag Wrangler v0.5.12
		22: Zoom v1.1.2
		23: Image Toolkit v1.4.0
		24: Footnote Shortcut v0.1.3
		25: Better footnote v1.0.1
		26: Projects v1.16.5
		27: Toggl Track v0.11.0
		28: Folder Note Core v1.3.5
		29: AidenLx's Folder Note v0.16.5
		30: YTranscript v0.8.2
		31: Timestamp Notes v1.0.8
		32: Buttons v0.4.19
		33: Natural Language Dates v0.6.1
		34: No more flickering inline math v0.1.3
		35: Auto Link Title v1.4.1
		36: Obsidian42 - Strange New Worlds (SNW) v1.2.2
		37: MathLinks v0.4.6
		38: Pandoc Reference List v2.0.22
		39: Obsidian Charts v3.7.2
		40: Excalidraw v1.9.19
		41: Quick Switcher++ v3.3.7
		42: Hover Editor v0.11.14
		43: Math Booster v1.0.0
		44: Floating Search v3.4.5
		45: Word Splitting for Japanese in Edit Mode v1.0.0
		46: Advanced URI v1.38.1
		47: QR Code Generator Plugin v1.1.0
		48: Search on Internet v0.5.0
		49: Templater v1.16.0
		50: Banners v2.0.0-beta
		51: Emoji Shortcodes v2.2.0
		52: Hider v1.3.1
		53: Filename Heading Sync v1.9.0

RECOMMENDATIONS:
	Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Also reproduced in the sandbox vault, with only Banners 2.0.0-beta and BRAT installed

SYSTEM INFO:
	Obsidian version: v1.4.13
	Installer version: v1.4.13
	Operating system: Darwin Kernel Version 22.3.0: Thu Jan  5 20:53:49 PST 2023; root:xnu-8792.81.2~2/RELEASE_X86_64 22.3.0
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 2
	Plugins enabled: 2
		1: Obsidian42 - BRAT v0.7.0
		2: Banners v2.0.0-beta

RECOMMENDATIONS:
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

URLs are supposed to be working here, but I think this is a bad link; reason being how GitHub handles images.
Media files (or at least image files) with github.com domains give a 404 (the image you mentioned is that: https://github.com/RyotaUshio/obsidian-math-booster/master/docs/fig/screenshot.png), but those with raw.githubusercontent.com work properly (same image: https://raw.githubusercontent.com/RyotaUshio/obsidian-math-booster/master/docs/fig/screenshot.png). I noticed that the image you pasted is using the former

Thank you, it worked perfectly!

image

It's just out of curiosity, but I still don't understand why the former type of link does work in v.1.3.3 (only in reading view).

Screen.Recording.2023-09-17.at.5.30.57.mov

Media files (or at least image files) with github.com domains give a 404 (the image you mentioned is that: https://github.com/RyotaUshio/obsidian-math-booster/master/docs/fig/screenshot.png),

I noticed you missed raw before master, I mean it's https://github.com/RyotaUshio/obsidian-math-booster/raw/master/docs/fig/screenshot.png, not https://github.com/RyotaUshio/obsidian-math-booster/master/docs/fig/screenshot.png.
It gives 404 without raw, but it doesn't with it.

Oh hm, that is a bit peculiar. I'm not sure how exactly how it works, but perhaps the raw part of the path acts as a redirect to the raw.githubusercontent.com URL. Obsidian also seems to throw some CORS errors with that link too, which I may be able to fix. But I'm not sure why it may work in one view and not the other

I'm not sure why it may work in one view and not the other

Do you mean v.1.3.3 can handle it in reading view but can't in live preview? If so, I'm sorry, it turned out it works if I set the "Properties in document" setting to "Source". (And the same happens for local images too.)

Screen.Recording.2023-09-17.at.5.48.38.mov

But exactly the same YAML doesn't work in v.2.0.0-beta.

Screen.Recording.2023-09-17.at.5.54.29.mov

OH, I missed that from before, I thought we were still talking about the v2-beta.
But yes, in 1.3.3, the banner actually does show with setting Properties in document to Source on the editing view, so that is what's supposed to happen.

As for v2's behavior, it looks like it is possibly CORS, which there is an Obsidian API function to use to avoid that issue, though I'd need to see if I can use it because of how I'm fetching the image

As you suggested, I simply replaced fetch() with requestUrl(), and then it worked! Please refer to the PR. (Or is it too naive?)

That does the trick actually! Will put this in the next beta release soon-ish, thank ya kindly