MediaService Class
This class is deprecated.
Provides information on media
Constructor
MediaService
-
provider
-
site
-
onlyThisSite
Parameters:
-
provider
MediaProvider -
site
StringSite uid to be used for this service
-
onlyThisSite
BooleanWhether 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:
-
content
StringThe 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:
-
fileName
String -
cb
Function
deleteById
-
mid
-
[options]
-
cb
Deletes a media descriptor by ID
Parameters:
-
mid
String | ObjectID -
[options]
Object optionalnot used in implementation
-
cb
Function
deleteContentByPath
-
mediaPath
-
cb
Parameters:
-
mediaPath
String -
cb
Function
existsByPath
-
mediaPath
-
cb
Parameters:
-
mediaPath
String -
cb
Function
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:
-
content
StringThe 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:
-
media
ArrayThe 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:
-
originalFilename
String
Returns:
generateMediaPath
-
originalFilename
Generates the path to uploaded media
Parameters:
-
originalFilename
String
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
-
-
cb
Object
getContentByPath
-
mediaPath
-
cb
Parameters:
-
mediaPath
String -
cb
Function
getContentStreamById
-
id
-
cb
Parameters:
-
id
String -
cb
Function
getContentStreamByPath
-
mediaPath
-
cb
Parameters:
-
mediaPath
String -
cb
Function
getMediaDescriptor
-
mediaUrl
-
cb
Generates a media descriptor for a given media URL
Parameters:
-
mediaUrl
String -
cb
FunctionA 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:
-
mid
StringThe 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:
-
mediaType
String
Returns:
getRendererByType
-
mediaUrl
-
isFile
Retrieves a media renderer for the specified URL
Parameters:
-
mediaUrl
StringThe media URL
-
isFile
BooleanTRUE 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:
-
type
StringThe 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:
-
position
StringCan 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:
-
renderer
MediaRendererAn implementation of MediaRenderer
-
view
StringThe 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:
-
mediaUrl
StringA URI string that points to a media resource
isRegistered
-
interfaceImplementation
Indicates if a media renderer is already registered
Parameters:
-
interfaceImplementation
Function | 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:
-
mediaPath
StringThe file path of the media
-
cb
FunctionCallback function
loadById
-
mid
-
cb
Loads a media descriptor by ID.
Parameters:
-
mid
String | ObjectIDMedia descriptor ID
-
cb
FunctionA callback that provides two parameters: an Error, if occurred and a media descriptor if found.
loadMediaProvider
-
context
Parameters:
-
context
Object-
site
String
-
Returns:
An instance of a media provider or NULL when no provider can be loaded.
registerRenderer
-
interfaceImplementation
Registers a media renderer
Parameters:
-
interfaceImplementation
Function | 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:
-
The
Stringmedia resource ID
-
options
Object-
[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.
-
-
cb
FunctionA 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:
-
flag
String | ObjectThe media resource ID
-
options
Object-
[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.
-
-
cb
FunctionA 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:
-
id
StringThe media resource ID
-
options
Object-
[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.
-
-
cb
FunctionA 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:
-
options
Object-
location
StringThe 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
-
-
cb
FunctionA 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:
-
media
Object -
[options]
Object optionalOptions object is not actually used in this implementation
-
cb
Function
setContent
-
fileDataStrOrBuff
-
fileName
-
cb
Parameters:
-
fileDataStrOrBuff
String | Buffer -
fileName
String -
cb
Function
setContentStream
-
stream
-
fileName
-
cb
Parameters:
-
stream
Stream -
fileName
String -
cb
Function
statByPath
-
mediaPath
-
cb
Parameters:
-
mediaPath
String -
cb
Function
unregisterRenderer
-
interfaceToUnregister
Unregisters a media renderer
Parameters:
-
interfaceToUnregister
Function | 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:
-
media
Object -
cb
FunctionA 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