-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed Image links #142
base: master
Are you sure you want to change the base?
Embed Image links #142
Conversation
Changed the way the image link are outputted so that they are embed ready instead of it just being a web link to the image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reupload the files but the actual changes are on lines
MALAPI: 119, 153, 184
src/api/apis/OMDbAPI.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reupload the files but the actual changes are on lines
OMDbAPI: 145, 177, 207
Please run the formatter so that the diffs become useful. |
If I might chime in, wouldn't it be easier to just have people who want it to be an embedded image for use in dataview to use a fixed dataview query to embed it?
If all the image property becomes an embedded image then it might mess up people's workflows for instance if they use the URL to download images or something similar. |
the dataview in the screenshot would be simpler and wouldnt just be limited to dataview, can you would be able to use it in something like would just be render as and the other set of pictures for example The image url is still there, it just makes it more useful within obsidian. For workflows that rely on the URL for downloading images, the URL can still be easily accessed and used as before. The change primarily aims to streamline the process of embedding images, making it more efficient in what the plugin does inside of obsidian. all this does in the end is have the plugin already do the work that would be needed for the end user to do. you ened up having to do
when it could have be as simple as doing
|
I believe that
I'm not convinced that the url is as easy to access as before, you'd have to strip the embed portion of the url each time Additionally you'd completely lose the ability to choose a specific size for the images, with the current URL I can just do this to embed an image in a note and have it be a specific size: It's all done automatically with a simple template and I don't see how it would be possible to choose specific sizes for images with this change. I would like for #137 and #134 to be added as well but those would be a lot less disruptive than changing the image url to an embed. Maybe if there was a toggle for it in the settings then people can choose? Edit: Additionally wouldn't it be best to change the other APIs to embed the image as well so the plugin remains consistent? |
yes you are right, this would allow inline dataview query to work as well with embeds from the yaml
the change is setup in away similar to a template as
which would allow the end user to give a title and allow whatever size they perfer to be input after importing the data with a blank
right, i didnt do the other Apis as i thought the embeds would be more useful in something that would commonly have the most use for it. i fear the plugin in of it self isnt the most consistent after looking through the code. |
But again this would force people who use this plugin to also use dataview if they want to be able to do any of that, it's an added dependency and then you notes are less future proof. Would it be alright if I just add a toggle in the settings and default it to off, so current users aren't impacted but they can change to it if they choose to? I'd also add the embedding to the other apis that have the image property. |
Absolutely, adding a toggle in the settings seems like a balanced solution that respects the needs/wants of all users. This way, those who prefer the current functionality can maintain their workflow, while others can opt-in to the new feature if they find it beneficial. extending the embedding functionality to other APIs that have the image property would enhance the overall utility of the plugin and something that i did overlooked. So, yes, please proceed with adding the toggle and extending the embedding functionality. I believe these changes will be welcomed by the community. |
Added an option for the poster embeds and also added embeds to the other apis
@@ -108,7 +108,7 @@ export class MALAPI extends APIModel { | |||
url: result.url, | |||
id: result.mal_id, | |||
|
|||
plot: result.synopsis, | |||
plot: result.synopsis ? result.synopsis.replace('[Written by MAL Rewrite]', '').trim() : '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and line 177 isnt need on the MALAPI.ts, this is suppose to remove the end comment return from pulling plot synopsis. No all of them had it and this was something i personally add on my end, that ened up getting pushed to PR, this doesnt need to be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems useful to keep
src/settings/Settings.ts
Outdated
@@ -279,6 +281,15 @@ export class MediaDbSettingTab extends PluginSettingTab { | |||
void this.plugin.saveSettings(); | |||
}); | |||
}); | |||
new Setting(containerEl) | |||
.setName('Embed posters in YAML') | |||
.setDesc('Embed the poster urls as images in the yaml to integrate with dataview.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pretty much sums it up nicely and no other way to put it, just adding a alternative
"Embed the URLs of the poster images within the image property using the image embedding syntax ![](URL)
. This will enable the images to directly integrate with Dataview, as opposed to simply being a hyperlink."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save image links as markdown embeds in the frontmatter, for easier handling with e.g. Dataview.
src/api/apis/BoardGameGeekAPI.ts
Outdated
@@ -75,7 +75,9 @@ export class BoardGameGeekAPI extends APIModel { | |||
const boardgame = response.querySelector('boardgame')!; | |||
const title = boardgame.querySelector('name[primary=true]')!.textContent!; | |||
const year = boardgame.querySelector('yearpublished')?.textContent ?? ''; | |||
const image = boardgame.querySelector('image')?.textContent ?? undefined; | |||
const image = this.plugin.settings.embedPosters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing the ternary everywhere seems bad, as it's a lot of code duplication. This would be better as a general post-process step applied to all data models after the individual APIs created them.
@@ -108,7 +108,7 @@ export class MALAPI extends APIModel { | |||
url: result.url, | |||
id: result.mal_id, | |||
|
|||
plot: result.synopsis, | |||
plot: result.synopsis ? result.synopsis.replace('[Written by MAL Rewrite]', '').trim() : '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems useful to keep
src/settings/Settings.ts
Outdated
@@ -279,6 +281,15 @@ export class MediaDbSettingTab extends PluginSettingTab { | |||
void this.plugin.saveSettings(); | |||
}); | |||
}); | |||
new Setting(containerEl) | |||
.setName('Embed posters in YAML') | |||
.setDesc('Embed the poster urls as images in the yaml to integrate with dataview.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save image links as markdown embeds in the frontmatter, for easier handling with e.g. Dataview.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my previous review I wasn't refering to just the one terneray that I marked, but all the ternerys for images. They all do more or less the same, this surrounding the link with an embed can be done once for all media type models in a post process step.
@@ -18,6 +18,11 @@ export class BoardGameGeekAPI extends APIModel { | |||
this.types = [MediaType.BoardGame]; | |||
} | |||
|
|||
processImageLink(boardgameElement: { querySelector: (arg0: string) => { (): any; new (): any; textContent: any } }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a better type for this, no? I am guessing boardgame
has a type that can be used here.
Changed the way the image link are outputted so that they are embed ready instead of it just being a web link to the image
this allows dataview to work without any extra steps