Show technical informationTechnical information
This is a read-only media provider that shows up in the media structure, exposing files from the website and allowing CMS console users to link directly to static files. Implements the "IMediaUrlProvider
" interface to ensure links are mapped to normal relative paths, and as such, this provider is safe to point even to the root of the website - it will not serve any protected files, since it does not serve files, just paths.
How to insert static images
First of all, make sure that the images you need are in the website folder (exposed as a read-only media store).
- From the System perspective, locate the folder exposed in the Media perspective (
~/download
by default). - Upload all the necessary image files there.
Next, insert images on the page:
- Edit a page.
- Place the cursor where you want to insert a static image.
- Insert > Image.
- Then in the Select Image window that shows up automatically, locate and expand the media store ("Static files from ~/download" by default).
- Select the image.
- Click OK in the Select Image window, then in the Insert Image window.
The image will appear on the page in Visual Editor.
The internal link to the image file will read "~/media(download:{GUID})
" where "download
" is the default ID of the media store.
<img src="/media(download:ee9411d9-925a-56d7-bfc8-2fa22b3b8175)" />
On the published page, it will be resolved as a relative link to a static file on the website.
<img src="/download/image.png" />
How to insert links to static files
First of all, make sure that the files you need are in the website folder (exposed as a read-only media store).
- From the System perspective, locate the folder exposed in the Media perspective (
~/download
by default). - Upload all the necessary files there.
Next, insert links to these files on the page:
- Edit a page.
- Select the portion of content to serve as a link.
- Click "Link" button.
- In the Insert Link window, click in the URL field.
- Then in the Select Page or File window, locate and expand the media store ("Static files from ~/download" by default).
- Select the file.
- Click OK in the SelectPage or File window, then in the Insert Link window.
The link will appear on the page in Visual Editor.
The internal link to the file will read "~/media(download:{GUID})
" where "download
" is the default ID of the media store.
<a href="/media(download:d827eab0-40a6-6fa4-0012-fd01beb1b835)">Download</a>
On the published page, it will be resolved as a relative link to a static file on the website.
<a href="/download/file.zip">Download</a>
Show information about exposing another website folder in the Media perspectiveHow to expose a website folder in the Media perspective
When installed, this add-on creates a folder on the website named "download" and using the IMediaProvider exposes it as the "Static files from ~/download" media store in the Media perspective.
When an image or a file from this media store is inserted, the GUID of the media file is prefixed with the ID of this media store - "download" by default.
The path to the website folder to expose, the label of the media store, its ID as well as the media provider's name are all configurable - in ~/App_Data/Composite/Composite.config
:
<configuration>
<!-- ... -->
<Composite.Data.Plugins.DataProviderConfiguration defaultDynamicTypeDataProviderName="DynamicXmlDataProvider">
<DataProviderPlugins>
<!-- ... -->
<add basePath="~/download"
storeTitle="Static files from ~/download"
storeDescription=""
storeId="download"
name="StaticFileLinkMediaProvider"
type="Orckestra.Media.StaticFileLinkMediaProvider.MediaProvider, Orckestra.Media.StaticFileLinkMediaProvider" />
</Composite.Data.Plugins.DataProviderConfiguration>
<!-- ... -->
</configuration>
You can change these default values or add another media provider specifying a different folder and a label as well as the new name and ID for the media provider. The media provider's name must be unique.
<add basePath="~/examples"
storeTitle="Examples"
storeDescription=""
storeId="examples"
name="AnotherStaticFileLinkMediaProvider"
type="Orckestra.Media.StaticFileLinkMediaProvider.MediaProvider, Orckestra.Media.StaticFileLinkMediaProvider" />
where the attributes are as follows:
- basePath: The relative path to the website folder, for example, ~/download
- storeTitle: The label of the media store to appear in the media tree, for example, "Static files from ~/download".
- storeDescription: the description of the media store
- storeId: The ID of the media store, will be used in the internal media links, for example, "download"
- name: The name for the media provider, for example, "StaticFileLinkMediaProvider". Must be unique
- type: The media provider. Must always be "
Orckestra.Media.StaticFileLinkMediaProvider.MediaProvider, Orckestra.Media.StaticFileLinkMediaProvider
" (unless some custom media provider is used instead)