joplin icon indicating copy to clipboard operation
joplin copied to clipboard

All: Add support for media links in plugin manifest.json

Open Retr0ve opened this issue 1 year ago • 5 comments

This feature is discussed at the forum

It adds a media field to manifest.json, a example:

{
    "media": [{
        "url": "https://raw.githubusercontent.com/laurent22/joplin/dev/Assets/ImageSources/RoundedCorners_64x64.png",
        "type": "image/png",
        "platform": "desktop",
        "label": "Description"
    }]
}

In the json above, the label member is a string that serves as an accessible name for the media. It can also serve as alternative text. The platform member is also a string that can define the distribution platform for which the specific media should apply to. It is reserved for future plugin systems on mobile devices. Potential values are desktop, and mobile. type is the MIME type of the media, it can be image/jpeg, image/png, image/gif, image/webp, video/mp4, video/webm, and video/ogg

I've tested this commit locally with the following test case:

  • media item without url
  • media item with platform other than desktop and mobile
  • media item with unsupported MIME type

Retr0ve avatar Jul 18 '22 09:07 Retr0ve

I don't think we'll support URLs as those can changed (in fact I'm surprised Chome supports this). We wouldn't want someone to swap the URL content for malware or something after we've validated the plugin.

So all media should be bundled with the plugin when webpack runs. Are you able to implement this?

laurent22 avatar Jul 22 '22 10:07 laurent22

That makes sense. Media files can be packed into .jpl file using file-loader in webpack, and we can extract them when building the plugin discovery site. But there is another problem, this might increase the size of the jpl file when someone tries to bundle a demo video. Is that something we should be concerned about?

Retr0ve avatar Jul 22 '22 11:07 Retr0ve

Let's not support videos for now.

And use this structure:

"screenshots": [ { "src": "path/to/image.png", "label": "Image description" },

For now we only have the src and label properties.

laurent22 avatar Jul 22 '22 12:07 laurent22

sounds good! I'll make some changes to the PR soon.

Retr0ve avatar Jul 22 '22 12:07 Retr0ve

I changed media to screenshots now and validate screenshots by their type and file size in this commit.

Retr0ve avatar Jul 28 '22 06:07 Retr0ve

Ok thank you, looks like it's ready to merge.

laurent22 avatar Aug 27 '22 11:08 laurent22