Difference between revisions of "Drupal Shortcodes"
(→Video Player Attributes)
|Line 99:||Line 99:|
can using this shortcode.
Revision as of 14:39, 19 September 2014
A "shortcode" is a snippet of text that allows you to insert special elements into your page. These can be placed in any WYSIWYG editor window.
The most common shortcode is used to embed video. To embed a video, get its URL from your video service of choice. For MiddMedia use the "HTTP (Download) URL". Here is an example of using the video embed code with a video from MiddMedia of the 2012 Convocation.
Supported Video Sources
We support video from the following sources.
- College Humor
- Flickr Video
- Flickr Slideshows
- Google Video
Video Player Attributes
You can change the appearance or behavior of the video player using attributes added to the shortcode. Not all of these work on videos from every source listed above. They should all work for videos from MiddMedia. The "width", "height" and "ratio" attributes can be used with any video. All of these are optional.
- Width written as
width:123where "123" is the desired width of the player, in pixels.
- Height written as
height:123where "123" is the desired height of the player, in pixels.
- Image written as
image:http://url_of_image.jpgputs a "splash" image over the video player, allowing you to highlight a particular frame if you have a separate image of it.
- Ratio written as
ratio:16/9allows you to set the aspect ratio of the video player. The default value is 16/9.
- Align written as
align:rightto align the video player to one side of the content.
- Autoplay written as
autoplay:0where "1" indicates that the video should play automatically when the page loads (discouraged) and "0" indicated that the video should only play when the user clicks the play button. The default is "0".
- Autorewind written as
autorewind:0where "1" indicates that after the video is done playing, the play bar is moved back to the beginning and "0" indicates that it is left at the end. The default is "0".
- Loop written as
loop:0where "1" indicates that the video should begin again after it is finished automatically and "0" indicates that it should not. The default value is "0".
A note about ratio: The default value of this attribute is 16/9. If you have a video that you want to play at a very precise pixel dimension, especially for large videos, or because you are using a specific splash image, you can set the ratio to the value of "width/height". Example:
width:589 height:374 ratio:589/374.
Here is an example of a video shortcode using all of these attributes:
[video:http://middmedia.middlebury.edu/media/Communications_LiveRecording-MIDD-web_data-middlebury-edu/mp4/2012Convocation.mp4 width:640 height:480 image:http://middmedia.middlebury.edu/media/Communications_LiveRecording-MIDD-web_data-middlebury-edu/splash/2012Convocation.jpg ratio:16/9 align:left autoplay:0 autorewind:0 loop:0]
You can add a YouTube playlist by adding the playlist ID in the video URL. For example:
In these examples, the playlist ID follows the "p=" or "list=" parts of the URL.
Audio uses the same shortcode as video, which might be confusing, but will work. The only supported source for audio files is MiddMedia. Here is an example of the shortcode to use for an audio file.
Unlike video, you cannot set the height, width or other attributes of the audio player.
You might want to add information about the labs that visitors to your site use. We can display the number of available machines in each of these labs to give people real-time information about their usage. To do this use the labserver shortcode.
[labserver] will print the total number of available machines in all computer labs.
[labserver 3] will print the total number of available machines in computer lab 3, which is Armstrong 161.
[labserver 65,43] will print the total number of available machines in computer labs 65 (LIB 105) and computer lab 43 (LIB 140) combined.
You can get the ID of the lab to use by clicking on any of the labs on the LabStats site and looking at the URL, which will include a "lab_id" parameter.
The LIS Librarians maintain subject guides in a system called "SubjectsPlus" to provide research resources to academic departments. If you would like to add one of these guides to your site, you can use the subjectsplus shortcode by including the SubjectsPlus subject code. For example, the URL of the American Studies subject guide is:
so the correct shortcode to use to include this guide is:
Some of the senior theses written by students are kept in the college archives and a list of these materials can be easily added to your site. Each thesis is included in one or more categories by department. To include this list, use the following shortcode.
And replace "Economics" with the name of your department from the "Academic Department 1" column in the student thesis repository. You can also include more than one department, for example:
List Manager Subscription Forms
You can embed a sign-up form for your List Manager mailing list in content using this shortcode, where the second part is the name of your mailing list. For example: