@electrolux-oss/sanity-plugin-media 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ This package includes source code from Sanity.io, licensed under the MIT license:
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2025 Sanity.io
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Sanity Media Plugin - Electrolux Version (for Sanity Studio v3)
2
+
3
+ > This plugin is for **Sanity Studio v3**.
4
+ > This is a forked version of Sanitys own [Media Plugin (v4.0.0)](https://github.com/sanity-io/sanity-plugin-media)
5
+
6
+ ## What is it?
7
+
8
+ A Sanity Studio v3 plugin that extends media handling capabilities with custom enhancements, based on a fork of an original plugin by Sanity.io.
9
+
10
+ A convenient way to browse, manage and refine your [Sanity](https://www.sanity.io/) assets.
11
+
12
+ Use it standalone as a browser, or optionally hook it up as a [custom asset source](https://www.sanity.io/docs/custom-asset-sources) and use it to power both image and file selection too.
13
+
14
+ ![Grid view](https://user-images.githubusercontent.com/209129/108927411-21aa7f00-7638-11eb-9cf7-334598ac4103.png)
15
+ _Default grid view_
16
+
17
+
18
+ _Asset details tab_ | _Asset alt texts tab_
19
+ :-------------------------:|:-------------------------:
20
+ ![first](https://github.com/user-attachments/assets/477b6576-a1a4-42e2-b2c2-2d2e962eb366) | ![second](https://github.com/user-attachments/assets/2c5bd907-1b60-48c6-a007-2f7304409007)
21
+
22
+
23
+ ## Features
24
+
25
+ #### Manage and organise your assets
26
+
27
+ - Support for batch uploads with drag and drop support
28
+ - Edit text fields native to Sanity's asset documents, such as `title`, `description`, `altTexts` and `originalFilename`
29
+ - View asset metadata and a limited subset of EXIF data, if present
30
+ - Tag your assets individually or in bulk
31
+ - Manage tags directly within the plugin
32
+ - Get previews for audio and video files
33
+ - Easily select and delete multiple assets in bulk
34
+
35
+ #### Granular search tools
36
+
37
+ - Refine your search with any combination of search facets such as filtering by tag name, asset usage, file size, orientation, type (and more)
38
+ - Use text search for a quick lookup by title, description and alt text
39
+
40
+ #### Built for large datasets and collaborative editing in mind
41
+
42
+ - Virtualized grid + tabular views for super speedy browsing, even with thousands of assets and tags
43
+ - Utilises Sanity's [real time updates](https://www.sanity.io/docs/realtime-updates) for live changes from other studio members
44
+
45
+ #### Fits right in with your Sanity studio
46
+
47
+ - Built with the same [UI components Sanity uses](https://www.sanity.io/ui) under the hood
48
+ - Fully responsive and mobile friendly
49
+
50
+ #### Added support for multi-language alt texts
51
+
52
+ - Define a list of available languages to enable multi-language alt texts for assets.
53
+ - See example of how to enable this feature [here](###plugin-config).
54
+
55
+ ## Install (Sanity Studio v3)
56
+
57
+ In your Sanity project folder:
58
+
59
+ ```sh
60
+ npm install --save sanity-plugin-media
61
+ ```
62
+
63
+ or
64
+
65
+ ```sh
66
+ yarn add sanity-plugin-media
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ Add it as a plugin in your `sanity.config.ts` (or .js) file:
72
+
73
+ ```js
74
+ import { media } from 'sanity-plugin-media'
75
+
76
+ export default defineConfig({
77
+ // ...
78
+ plugins: [
79
+ media(
80
+ languages: [
81
+ { code: 'en-US', title: 'English', default: true },
82
+ { code: 'sv-SE', title: 'Swedish' },
83
+ { code: 'fr-FR', title: 'French' },
84
+ { code: 'de-DE', title: 'German' }
85
+ ],
86
+ )
87
+ ]
88
+ })
89
+ ```
90
+
91
+ This will enable the Media plugin as both a standalone tool (accessible in your studio menu) and as an additional asset source for your image and file fields.
92
+
93
+ ### Customizing the asset source
94
+
95
+ You can configure your studio to use this asset source either exclusively, or conditionally enable it based on the type of asset (image or file).
96
+
97
+ ```js
98
+ import { media, mediaAssetSource } from 'sanity-plugin-media'
99
+
100
+ export default defineConfig({
101
+ // ...
102
+ plugins: [media()],
103
+ form: {
104
+ // Don't use this plugin when selecting files only (but allow all other enabled asset sources)
105
+ file: {
106
+ assetSources: previousAssetSources => {
107
+ return previousAssetSources.filter(assetSource => assetSource !== mediaAssetSource)
108
+ }
109
+ }
110
+ }
111
+ })
112
+ ```
113
+
114
+ ### Plugin Config
115
+
116
+ ```ts
117
+ // sanity.config.ts
118
+ export default defineConfig({
119
+ //...
120
+ plugins: [
121
+ media({
122
+ // { code: string; title: string, default?: boolean }[] - the list of languages used for alt texts
123
+ // NOTE! Set only one language to default: true.
124
+ languages: [
125
+ { code: 'en-US', title: 'English', default: true },
126
+ { code: 'sv-SE', title: 'Swedish' },
127
+ { code: 'fr-FR', title: 'French' },
128
+ { code: 'de-DE', title: 'German' }
129
+ ],
130
+ creditLine: {
131
+ enabled: true,
132
+ // boolean - enables an optional "Credit Line" field in the plugin.
133
+ // Used to store credits e.g. photographer, licence information
134
+ excludeSources: ['unsplash'],
135
+ // string | string[] - when used with 3rd party asset sources, you may
136
+ // wish to prevent users overwriting the creditLine based on the `source.name`
137
+ },
138
+ maximumUploadSize: 10000000
139
+ // number - maximum file size (in bytes) that can be uploaded through the plugin interface
140
+ })
141
+ ],
142
+ })
143
+ ```
144
+
145
+ ## Develop locally
146
+
147
+ ### Test your plugin locally
148
+
149
+ In the plugin directory run this command:
150
+ ```sh
151
+ npm run link-watch
152
+ ```
153
+
154
+ This will set up your plugin to build whenever the code changes, and publish the package to a local yalc repository.
155
+
156
+ In the command log, there should be a note that reads something like this:
157
+
158
+ ```sh
159
+ npx yalc add sanity-plugin-media-elux && npx yalc link sanity-plugin-media-elux && npm install
160
+ ```
161
+
162
+ Run this command in the studio project directory and you should see something like this in the `package.json` file:
163
+
164
+ ```
165
+ "sanity-plugin-media-elux": "file:.yalc/sanity-plugin-media-elux",
166
+ ```
167
+
168
+ Which means you can safely use the local version of the plugin with this import:
169
+
170
+ ```
171
+ import { media } from 'sanity-plugin-media-elux'
172
+ ```
@@ -0,0 +1,32 @@
1
+ import { AssetSourceComponentProps } from 'sanity'
2
+ import { ForwardRefExoticComponent } from 'react'
3
+ import { JSX as JSX_2 } from 'react'
4
+ import { Plugin as Plugin_2 } from 'sanity'
5
+ import { RefAttributes } from 'react'
6
+ import { SVGProps } from 'react'
7
+
8
+ export declare const media: Plugin_2<void | MediaToolOptions>
9
+
10
+ export declare const mediaAssetSource: {
11
+ component: (props: AssetSourceComponentProps) => JSX_2.Element
12
+ icon: ForwardRefExoticComponent<
13
+ Omit<SVGProps<SVGSVGElement>, 'ref'> & RefAttributes<SVGSVGElement>
14
+ >
15
+ name: string
16
+ title: string
17
+ }
18
+
19
+ export declare type MediaToolOptions = {
20
+ languages: {
21
+ code: string
22
+ title: string
23
+ default?: boolean
24
+ }[]
25
+ maximumUploadSize?: number
26
+ creditLine: {
27
+ enabled: boolean
28
+ excludeSources?: string | string[]
29
+ }
30
+ }
31
+
32
+ export {}
@@ -0,0 +1,32 @@
1
+ import { AssetSourceComponentProps } from 'sanity'
2
+ import { ForwardRefExoticComponent } from 'react'
3
+ import { JSX as JSX_2 } from 'react'
4
+ import { Plugin as Plugin_2 } from 'sanity'
5
+ import { RefAttributes } from 'react'
6
+ import { SVGProps } from 'react'
7
+
8
+ export declare const media: Plugin_2<void | MediaToolOptions>
9
+
10
+ export declare const mediaAssetSource: {
11
+ component: (props: AssetSourceComponentProps) => JSX_2.Element
12
+ icon: ForwardRefExoticComponent<
13
+ Omit<SVGProps<SVGSVGElement>, 'ref'> & RefAttributes<SVGSVGElement>
14
+ >
15
+ name: string
16
+ title: string
17
+ }
18
+
19
+ export declare type MediaToolOptions = {
20
+ languages: {
21
+ code: string
22
+ title: string
23
+ default?: boolean
24
+ }[]
25
+ maximumUploadSize?: number
26
+ creditLine: {
27
+ enabled: boolean
28
+ excludeSources?: string | string[]
29
+ }
30
+ }
31
+
32
+ export {}