MediaService Class
This class is deprecated.
Provides information on media
Constructor
MediaService
-
provider -
site -
onlyThisSite
Parameters:
-
providerMediaProvider -
siteStringSite uid to be used for this service
-
onlyThisSiteBooleanWhether this service should only return media associated with specified site or fallback to global if not found in specified site
Item Index
Methods
- . static
- createContentWriteStream
- deleteById
- deleteContentByPath
- existsByPath
- extractNextMediaFlag static deprecated
- findProviderType static deprecated
- formatMedia static deprecated
- generateFilename static deprecated
- generateMediaPath static deprecated
- get
- getContentByPath
- getContentStreamById
- getContentStreamByPath
- getMediaDescriptor
- getMediaFlag static deprecated
- getMediaIcon static deprecated
- getRendererByType static deprecated
- getRendererByType static deprecated
- getStyleForPosition static deprecated
- getStyleForView static deprecated
- getSupportedExtensions static deprecated
- isFile static deprecated
- isRegistered static deprecated
- isValidFilePath
- loadById
- loadMediaProvider static deprecated
- registerRenderer static deprecated
- render
- render
- renderById
- renderByLocation
- save
- setContent
- setContentStream
- statByPath
- unregisterRenderer static deprecated
- validate
Properties
- COLL static
- provider
- site
- siteQueryService
Methods
.
-
content
Parses a media flag and returns each part in an object. The parsed value that is returned will include:
- id - The media descriptor id that is referenced by the media flag
- style - A hash of the style properties declared for the flag
- cleanFlag - The media flag stripped of the start and end markers
Parameters:
-
contentStringThe content string that potentially contains 1 or more media flags
Returns:
An object that contains the information about the parsed media flag.
createContentWriteStream
-
fileName -
cb
Parameters:
-
fileNameString -
cbFunction
deleteById
-
mid -
[options] -
cb
Deletes a media descriptor by ID
Parameters:
-
midString | ObjectID -
[options]Object optionalnot used in implementation
-
cbFunction
deleteContentByPath
-
mediaPath -
cb
Parameters:
-
mediaPathString -
cbFunction
existsByPath
-
mediaPath -
cb
Parameters:
-
mediaPathString -
cbFunction
extractNextMediaFlag
-
content
Given a content string the function will search for and extract the first occurrence of a media flag. The parsed value that is returned will include:
- startIndex - The index where the flag was found to start
- endIndex - The position in the content string of the last character of the media flag
- flag - The entire media flag including the start and end markers
- id - The media descriptor id that is referenced by the media flag
- style - A hash of the style properties declared for the flag
- cleanFlag - The media flag stripped of the start and end markers
Parameters:
-
contentStringThe content string that potentially contains 1 or more media flags
Returns:
An object that contains the information about the parsed media flag.
findProviderType
()
MediaProvider
deprecated
static
Looks up the prototype for the media provider based on the configuration
Returns:
formatMedia
-
media
Sets the proper icon and link for an array of media items
Parameters:
-
mediaArrayThe array of media objects to format
Returns:
The same array of media that was passed in
generateFilename
-
originalFilename
Generates a filename for a new media object
Parameters:
-
originalFilenameString
Returns:
generateMediaPath
-
originalFilename
Generates the path to uploaded media
Parameters:
-
originalFilenameString
Returns:
get
-
[options] -
cb
Queries for media descriptors
Parameters:
-
[options]Object optional-
[where]Object optional -
[order]Array optional -
[select]Object optional -
[limit]Integer optional -
[offset]Integer optional -
[format_media=true]Boolean optional
-
-
cbObject
getContentByPath
-
mediaPath -
cb
Parameters:
-
mediaPathString -
cbFunction
getContentStreamById
-
id -
cb
Parameters:
-
idString -
cbFunction
getContentStreamByPath
-
mediaPath -
cb
Parameters:
-
mediaPathString -
cbFunction
getMediaDescriptor
-
mediaUrl -
cb
Generates a media descriptor for a given media URL
Parameters:
-
mediaUrlString -
cbFunctionA callback with two parameters. First, an Error if occurred and second is an object that describes the media resource described by the given media URL
getMediaFlag
-
mid -
[options]
Generates a media placeholder for templating
Parameters:
-
midStringThe media descriptor ID
-
[options]Object optionalThe list of attributes to be provided to the rendering element.
Returns:
getMediaIcon
-
mediaType
Retrieves the font awesome icon for the media type.
Parameters:
-
mediaTypeString
Returns:
getRendererByType
-
mediaUrl -
isFile
Retrieves a media renderer for the specified URL
Parameters:
-
mediaUrlStringThe media URL
-
isFileBooleanTRUE if the URL represents an uploaded file, FALSE if not
Returns:
A media renderer interface implementation or NULL if none support the given URL.
getRendererByType
-
type
Retrieves a media renderer for the specified type
Parameters:
-
typeStringThe media type
Returns:
A media renderer interface implementation or NULL if none support the given type.
getStyleForPosition
-
position
The default editor implementations all for three position values to declared for embeded media (none, left, right, center). These values map to HTML alignments. This function retrieves the HTML style attribute for the provided position.
Parameters:
-
positionStringCan be one of 4 values: none, left, right, center
Returns:
The HTML formatted style attribute(s)
getStyleForView
-
renderer -
view -
[overrides]
Retrieves the base style for the given renderer and view. Overrides will be applied on top of the base style.
Parameters:
-
rendererMediaRendererAn implementation of MediaRenderer
-
viewStringThe view to retrieve the default styling for (view, editor, post)
-
[overrides]Object optionalA hash of style properties that will be applied to the base style for the given view
getSupportedExtensions
()
Array
deprecated
static
Provides a mechanism to retrieve all of the supported extension types that can be uploaded into the system.
Returns:
provides an array of strings
isFile
-
mediaUrl
Determines if the media URI is a file. It is determined to be a file if and only if the URI does not begin with "http" or "//".
Parameters:
-
mediaUrlStringA URI string that points to a media resource
isRegistered
-
interfaceImplementation
Indicates if a media renderer is already registered
Parameters:
-
interfaceImplementationFunction | ObjectA prototype or object that implements the media renderer interface
Returns:
TRUE if registered, FALSE if not
isValidFilePath
-
mediaPath -
cb
Retrieves whether a media's file path is valid
Parameters:
-
mediaPathStringThe file path of the media
-
cbFunctionCallback function
loadById
-
mid -
cb
Loads a media descriptor by ID.
Parameters:
-
midString | ObjectIDMedia descriptor ID
-
cbFunctionA callback that provides two parameters: an Error, if occurred and a media descriptor if found.
loadMediaProvider
-
context
Parameters:
-
contextObject-
siteString
-
Returns:
An instance of a media provider or NULL when no provider can be loaded.
registerRenderer
-
interfaceImplementation
Registers a media renderer
Parameters:
-
interfaceImplementationFunction | ObjectA prototype or object that implements the media renderer interface.
Returns:
TRUE if the implementation was registered, FALSE if not
render
-
The -
options -
cb
Renders the media represented by the provided media descriptor.
Parameters:
-
TheStringmedia resource ID
-
optionsObject-
[attrs]Object optionalThe desired HTML attributes that will be added to the element that provides the rendering
-
[style]Object optionalThe desired style overrides for the media
-
[view]String optionalThe view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.
-
-
cbFunctionA callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.
render
-
flag -
options -
cb
Renders the media represented by the provided media flag
Parameters:
-
flagString | ObjectThe media resource ID
-
optionsObject-
[attrs]Object optionalThe desired HTML attributes that will be added to the element that provides the rendering
-
[style]Object optionalThe desired style overrides for the media
-
[view]String optionalThe view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.
-
-
cbFunctionA callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.
renderById
-
id -
options -
cb
Renders a media resource by ID where ID refers the to the media descriptor id.
Parameters:
-
idStringThe media resource ID
-
optionsObject-
[attrs]Object optionalThe desired HTML attributes that will be added to the element that provides the rendering
-
[style]Object optionalThe desired style overrides for the media
-
[view]String optionalThe view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.
-
-
cbFunctionA callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.
renderByLocation
-
options -
cb
Renders a resource by type and location (mediaId).
Parameters:
-
optionsObject-
locationStringThe unique media identifier for the type
-
[type]String optionalThe type of provider that knows how to render the resource
-
[attrs]Object optionalThe desired HTML attributes that will be added to the element that provides the rendering
-
[style]Object optionalThe desired style overrides for the media
-
[view]String optionalThe view type that the media will be rendered for (view, editor, post). Any style options provided will override those provided by the default style associated with the view.
-
[isFile=false]Boolean optional
-
-
cbFunctionA callback that provides two parameters. An Error if exists and the rendered HTML content for the media resource.
save
-
media -
[options] -
cb
Persists a media descriptor
Parameters:
-
mediaObject -
[options]Object optionalOptions object is not actually used in this implementation
-
cbFunction
setContent
-
fileDataStrOrBuff -
fileName -
cb
Parameters:
-
fileDataStrOrBuffString | Buffer -
fileNameString -
cbFunction
setContentStream
-
stream -
fileName -
cb
Parameters:
-
streamStream -
fileNameString -
cbFunction
statByPath
-
mediaPath -
cb
Parameters:
-
mediaPathString -
cbFunction
unregisterRenderer
-
interfaceToUnregister
Unregisters a media renderer
Parameters:
-
interfaceToUnregisterFunction | ObjectA prototype or object that implements the media renderer interface
Returns:
TRUE if unregistered, FALSE if not
validate
-
media -
cb
Validates a media descriptor
Parameters:
-
mediaObject -
cbFunctionA callback that provides two parameters: an Error, if occurred. The second is an array of validation error objects.
Properties
COLL
String
static
The collection where media descriptors are persisted
