glFusion Wiki

Site Tools


Media Items

The heart of Media Gallery is the actual media you upload into your albums. Media Gallery supports a wide range of media types. Media Gallery has some unique methods to handle your uploaded media, below is an overview of how Media Gallery processes the media items.

Media Gallery does not store your images and other media items outside of the web root. This means, it is possible that a user could view your media items directly, bypassing the glFusion security model. Don't panic, there are controls in place to minimize this, but it is possible. You will need to decide if the controls Media Gallery has in place will meet your needs and requirements.

Unlike many gallery solutions, Media Gallery does not store your media items in subdirectories that are named after the album in which they reside. Instead, there is no relationship to the album and the physical directory where the media items are stored. Media Gallery has 16 directories, named 0-f, where it will store your media items.

Also, Media Gallery will use a unique hash algorithm to create the actual filename used to store your media. An example is 09b1867c5238c1c9035bc73f76b29bf4.jpg.

These two features add to the overall security of your media items since it would be almost impossible for someone to actually guess both the directory name and the unique hash filename. But, this also makes it very difficult to export your media items or physically manage your files locally.

There is an option to disable the unique hash naming feature, instead Media Gallery will simply use the original filename of the media item instead. This makes downloading the item a little less confusing.

Media Gallery never displays the item filename in a URL. The filenames are disclosed in the rendered HTML page, in the image tags. My thought here is that if you give a user access to the album through Media Gallery and they use the View Source option of their browser to see the actual filenames, they already have access to the media item anyway.

I believe the media items have an appropriate level of protection that will prevent a non-site user from viewing your media items directly.

A concern that I have heard voiced is the ability for other sites to hot link to your media items. Basically, making them available to their site, but using your bandwidth. There are several options available outside of glFusion and Media Gallery to prevent this from happening. Most hosting services offer a method to prevent hot linking. If you are running the Apache web server, there are many solutions to prevent hot linking. If you are running Microsoft's IIS server, there are ISAPI filters available to prevent this as well. Do a Google search on “hot link protection” and you will be presented with several options.

One note of caution, if you choose to use a hot link protection method and also give your site users the ability to print images using the integrated online printing feature of Media Gallery, you will need to allow the domain to pull images directly from your site. Be sure and include in the allowed exception list.

A quick note on why Media Gallery was designed this way. When I first wrote the initial version of Media Gallery, I did store all the items outside of the web root, only allowing access through the program. I found several problems and issues with this approach over time. Browsers did not cache the content, since it was dynamically sent each time. Some privacy tools and ad blockers would block the content. I decided on a compromise, let the images be directly accessible, with a naming and storage convention that would make it very difficult to guess. So far, this solution has proven to be a successful one. I understand there may be some users who feel they need a 100% guarantee that no one outside of their logged-in website users can access their media items. Unfortunately, in this case, Media Gallery is probably not the best solution. I would recommend looking at the Gallery2 Bridge that supports embedding Gallery v2.1 into glFusion, Gallery v2 does support storing the images outside of the web root.

Supported Media Types

Media Gallery supports a wide range of media. Including image, video, audio and any other type of item you wish to add. You can control what types of media are allowed on a per album basis. Also, depending on the Graphics Package you are using, some media types may or may not be supported.

Image Media

Media Gallery will automatically convert all uploaded image media to JPG format. There is an option you can specify during the upload (Browser based upload only) to disable the conversion.

JPG, JPEGJPG is a commonly used compression / storage format for image media.
PNGPNG is a bitmap image format that employs lossless data compression.
TIFTagged Image File Format is mainly used for storing image media. TIF format is only supported by the ImageMagick graphics package.
GIFGraphics Interchange Format an 8-bit-per-pixel bitmap image format that was introduced by CompuServe in 1987 and has since come into widespread usage on the World Wide Web due to its wide support and portability.
BMPBMP is a bitmapped graphics format used internally by the Microsoft Windows and OS/2 graphics subsystem (GDI), and used commonly as a simple graphics file format on those platforms.
TGATGA File Format, often referred to as TARGA File Format, is a raster graphics file format.
PSDThe .PSD (Photoshop Document) format stores an image with support for most imaging options available in Photoshop. These include layers with masks, color spaces, ICC profiles, transparency, text, alpha channels, spot colors, clipping paths, and Duotone settings. The PSD format is only supported by the ImageMagick graphics package.

Audio / Video Media

MP3MP3, is a popular audio encoding format. It uses a lossy compression algorithm that is designed to greatly reduce the amount of data required to represent the audio recording, yet still sound like a faithful reproduction of the original uncompressed audio to most listeners.
OGGOgg is an open standard for a free container format for digital multimedia, unrestricted by software patents and designed for efficient streaming and manipulation.
WMVWMV (*.wmv) files use Microsoft's ASF container format. These files can be played by Windows Media Player and other players such as MPlayer, the VLC media player or Media Player Classic.
SWFSWF is a proprietary vector graphics file format produced by the Flash software from Adobe (formerly Macromedia). Intended to be small enough for publication on the web, SWF files can contain animations or applets of varying degrees of interactivity and function.
MOVThe QuickTime (.mov) file format functions as a multimedia container file that contains one or more tracks, each of which stores a particular type of data: audio, video, effects, or text (for subtitles, for example).
MP4 / MPEGMP4 is a multimedia container format standard specified as a part of MPEG-4. It is most commonly used to store digital audio and digital video streams, especially those defined by MPEG, but can also be used to store other data such as subtitles and still images.
FLVFlash Video (FLV) is a proprietary file format used to deliver video over the Internet using Adobe Flash Player (formerly known as Macromedia Flash Player) version 6, 7, 8, or 9.
Streaming FLVSame as above, but referencing a streaming flash video server. To use streaming FLV files, you must have a streaming Flash video server.
Embedded VideoAny embedded video from sites such as YouTube or Google Video.

Media Gallery will determine if there is an embedded thumbnail image in an uploaded MP3 file. If there is, Media Gallery will extract it and automatically use it as the attached thumbnail for the audio file.

Media Gallery will also pull the title,artist, and genre for the embedded tags and use these to auto fill the media title, description and keywords.

MP4 files with H.264 video and AAC audio: To use Flowplayer instead of QuickTime to play these files, edit your private/plugins/mediagallery/config.php and add the following line:

$_MG_CONF['play_mp4_flv'] = true;

If the MP4 files are downloaded completely before playback starts in Flowplayer or QuickTime, you'll need to move the metadata from the end to the beginning to allow streaming. This is accomplished with the MetadataMover (Windows only) tool.

Other Media Types

ZIPIf configured, Media Gallery can extract a ZIP file and process the contents inside.
OtherAllows any other type of media not defined above to be placed in the album.

Media Handling Overview

Media Gallery will create a thumbnail and display image for all uploaded image media. This means that Media Gallery will maintain three different copies of an image. The decision to create static thumbnails and display images was based on performance. An image is uploaded once, but viewed many times. It make sense to create the thumbnail/display image one time and display it many times instead of dynamically creating the thumbnail/display image each time it is displayed. There is a huge performance gain and this gives Media Gallery the ability to scale to higher number of concurrent users. The downside is there is a large disk space requirement since these images are statically stored on the server.

When new media is uploaded to Media Gallery, there are several actions performed. Many of the actions are controlled via the album configuration.

When a new image is uploaded, Media Gallery will do the following:

  • Validate the user has permissions to upload to the album.
  • Validate the image type is allowed by the album configuration.
  • Validate the image does not exceed the maximum file size as defined by the album configuration.
  • Create a thumbnail image.
  • Create a display image.
  • Check the Media Gallery configuration option on whether the original uploaded image should be kept.
  • Check the album configuration to determine if the original image needs to be resized.
  • Check the album configuration to determine if the image needs to be watermarked.
  • Check the album configuration to determine if the image should be placed in the moderation queue and if moderators should be notified of the upload.

When new video media is uploaded, Media Gallery will do the following:

  • Validate the user has permission to upload to the album.
  • Validate the video type is allowed by the album configuration.
  • Validate the video does not exceed the maximum file size as defined by the album configuration.
  • Check the Media Gallery configuration if FFMpeg should try to create a thumbnail of the video.
  • Check the album configuration to determine if the video should be placed in the moderation queue and if the moderators should be notified of the upload.

When new audio media is uploaded, Media Gallery will do the following:

  • Validate the user has permission to upload to the album.
  • Validate the audio type is allowed by the album configuration.
  • Validate the audio file does not exceed the maximum file size as defined by the album configuration.
  • Attempt to extract any embedded thumbnail images in the MP3 file.
  • Attempt to extract any IDv3 meta data to automatically populate the media title / description fields.
  • Check the album configuration to determine if the audio file should be placed in the moderation queue and if moderators should be notified of the upload.

As you can see, how Media Gallery deals with new media is very dependent upon how the album is configured.

Uploading Media

Media Gallery supports several methods to add media to your albums; Direct Browser Uploads, Import via FTP, Upload via the JUPLOAD Java Applet, and the Windows Web Publishing Wizard.

Before we get into the details about how to add media to your albums, there needs to be a little discussion on outside factors that affect uploading to your albums. Server configuration and PHP's configuration play a major role in how uploads work and what can be uploaded. For example, PHP's configuration file (php.ini) controls the maximum file size that can be uploaded. It also controls the maximum size of a page that can be submitted. See this online FAQ for more information.

Let's discuss the options for adding media to your albums:

Direct Browser Uploads

This option allows you to upload media to an album. You must specify a caption for each uploaded file; the description field and keyword fields are optional. You may also upload a thumbnail with each item you upload for the album.

Browser uploading is very convenient, but it does limit the size and how many items you can upload at one time. For example, if your PHP configuration only allows 2 megabytes file uploads, you cannot upload anything larger through the browser upload screen. If you have 20 or 30 items to upload, you can only upload a maximum of 4 items at a time with the browser upload.

FTP Import

Import via FTP offers a much more flexible method to add items to your albums. There are no real limits on how many items you can add at a time or file size limitations like those of the Direct Browser Upload.

To use Import via FTP, you must first transfer your media items to your server and store them in a temporary directory. Usually this is done using an FTP program (I prefer FileZilla, a flexible and free FTP utility for several platforms). Once you have uploaded your media items with your FTP client, you use the FTP Import option to move them into your albums.

You must upload your media to the directory specified in the System Configuration FTP Path.

Adding media items via FTP import also offers a few other advantages. Media Gallery can automatically create albums based on sub-directory names making it very easy and convenient to add a large number of items to your Media Gallery.

For example, if your FTP directory contains:

  / +- vacation pictures 
    +- school pictures 
    +- outdoor pictures 

Media Gallery will automatically create the albums called: vacation pictures, school pictures and outdoor pictures. Media Gallery will use the album defaults when creating the albums.

If you Import via FTP your MP3 or OGG files, during the import, Media Gallery will pull the title and artist information (if available) and place it in the title field automatically.

Gallery Remote is a JAVA applet developed by the Gallery Project. They are gracious enough to publish their API and specifications so it can be integrated into other projects.

With Media Gallery v1.4.4 and above, there is full support for using Gallery Remote as an upload tool.

To use Gallery Remote, it is as simple as downloading the applet and installing it on your computer. Once you have it installed, setup a connection for your Media Gallery site by choosing Add Gallery URL, the url would be

JUPLOAD Java Applet

JUPLOAD is a JAVA upload applet. From the JUPLOAD website:

To use JUPLOAD, you must have the Java Runtime Environment installed on your local computer. Once the applet is started, you can select the destination album for your uploads via the Album Select drop down menu, then using the JUPLOAD applet, select which files you wish to upload and submit.

Windows Web Publishing Wizard

Media Gallery supports uploading directly from Microsoft Windows XP, using the Web Publishing Wizard. This is a very easy and convenient method to place media items into your albums.

Microsoft officially removed the “Web Publishing Wizard” from Windows Vista.

Before you can use the Web Publishing Wizard, you must first tell Windows about your site, this is done by installing a small registry file that will give Windows the details about your site.

To get this registry file, go into the Media Gallery Upload Screen and select the Windows Publishing tab. Select the correct registry file for your operating system. Install this registry file in Windows by either double clicking on the saved file, or by choosing 'Run' from the download dialog box.

You are now ready to publish to your Media Gallery installation directly from Windows XP.

Open up a folder with images or other media items you wish to publish, look in the left menu under File and Folder Tasks and you should see Publish this folder to the Web. If you had selected only a couple of items to publish by first highlighting them in Windows Explorer, it would read Publish the selected items to the Web.

Follow the Windows prompts until you get to the 'Select Provider' screen, here you should see your website. If not, you need to install the registry entries by following the procedure above.

You will need to sign on (the wizard will prompt you for your glFusion username and password).

You should see a list of your albums now, select the one you want and select Next. Or, you can create an album at this point, simply choose 'Create Album' button and follow the prompts.

You will be asked if you want to resize the files before uploading. This is up to you, if you choose to resize your files, it will generally decrease the time necessary to upload the items, but Windows XP can alter or destroy some of the embedded EXIF information during the resize. Also, if you choose to allow your users to utilize the On line Printing Feature, the smaller you make the original image, the fewer options your users will have when printing the images. For example, they will not be able to print a 16×20 inch photograph if the original size is changed to 1024×768 pixels. Decide if you want your images resized and then select Next.

Your files should now start uploading.

The Windows Web Publishing Wizard is not very good about reporting errors, you will want to check your glFusion error.log if there were any problems uploading your files.

Keep in mind that the Windows Web Publishing Wizard is under the same size restrictions as uploading via the browser. So if your PHP installation has a maximum file size of 2 megabytes, that would be the largest file you can upload through the publishing wizard as well.

Once the wizard has completed the upload, it will log you out of the website.

In order to force the logout at the end of the uploads, Media Gallery tricks the XP Publishing Wizard by placing a dummy upload record at the end of the XML manifest. This causes the XP Publishing Wizard to report and extra file on the upload. So, if you are uploading 10 images, the XP Publishing Wizard will actually report x of 11 images uploaded. Don't be alarmed that the image count is incorrect, it does not affect the items you upload and it is purely cosmetic.

Uploading ZIP Files

If you have enabled ZIP file support in the System Options, you can upload a ZIP file containing images. Media Gallery will unzip the file, including any embedded sub-directories, and then import each of the files. Just like in the FTP Import, Media Gallery will automatically create albums for each sub-directory found in the ZIP archive.

Uploading Streaming FLV or Embedded Media

To add streaming / remote media items to your Media Gallery albums, when you select Add Media there is a new tab called Remote Media. Select this tab and a new upload form will display.

Upload Fields:

  • Remote Media Type - there are two choices, Streaming FLV and Embedded Video.
  • Thumbnail - If you want to attach a thumbnail to the remote media, specify it here.
  • Remote URL - This will be the URL to the streamed Flash Video File (i.e. rtmp:// Or, if you are adding an embedded video, place the full embed code from the source site.
  • Width / Height - This is only valid for streaming Flash Video, provide the playback height and width. For embedded video, the playback size is specified in the embed string.

Uploading Remote Images

Media Gallery has limited support for including remotely hosted image files in your albums. To utilize this feature, your web hosting environment must support accessing remote files. This means that PHP must either have the CURL extension loaded, or have the remote URL wrapper enabled.

Enabling Remote Image Support

Before you can use the Remote Image support, you must first configure Media Gallery to use this feature, it is disabled by default. Edit the Media Gallery config.php file (located in the private/plugins/mediagallery/ directory) and set $_MG_CONF['enable_remote_images'] to true:

  $_MG_CONF['enable_remote_images'] = true;

Uploading Remote Images

To add remote images to your Media Gallery albums, when you select Add Media there is a tab called Remote Media. Select this tab and a new upload form will display.

Select the appropriate image type (JPEG, GIF) for the remote image. Enter the full URL to the remote image.

Post Upload Processing

FFmpeg Video Thumbnail Support

FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed under Linux, but it can compiled under most operating systems, including Windows.

Media Gallery uses FFmpeg to automatically create thumbnails for uploaded videos. In order to use FFmpeg, it must be available on your web server. I have found that many hosting providers do not like to install FFmpeg because it can take a significant amount of resources, so you may have to either compile and install it yourself, or locate a precompiled version to install. I recommend that you use Google's search to find a precompiled version for you environment if necessary.

I have also found that there seems to be many different versions of FFmpeg out there, each with a slightly different set of support and command line options. To make Media Gallery as flexible as possible, you can customize exactly how FFmpeg is called.

In Media Gallery's config.php file you will see the following entry:

$_MG_CONF['ffmpeg_command_args'] = ' -i %s -f mjpeg -t 0.01 -y %s';

This controls how FFmpeg is called. In this example, the full command for FFmpeg would be:

ffmpeg -i INPUTFILE -f mjpeg -t 0.01 -y OUTPUTFILE

You will see that there are several example command lines in the config.php file, you may need to experiment with each one to find the one that works best in your environment.

No FFmpeg Support?

If you do not have FFmpeg available on your web server, you can still use it locally on your workstation to create thumbnails from video files and simply attach them to the video through Media Gallery's upload interface.

There are several versions of FFmpeg out there for most operating systems. Try searching Google if none of the solutions below meet your needs.

Windows XP / Vista

For Windows users, there is a freely available version of FFmpeg available from Riva. This utility will create thumbnails and also convert various video formats to Flash Video.

If you wish to use it directly and/or without installing anything, ffmpeg.exe is directly shipped inside the freeware FLV Converter. FLV Converter is just ffmpeg.exe alongside a simple FLV front-end, and is meant to help you easily use ffmpeg to convert FLV files to AVI/MPG/MP2 formats (by creating a batch file that uses ffmpeg.exe with all of the right parameters). Of course, you don't have to use the FLV only front-end, especially since its AVI output setting is not configured correctly anyway (it can be easily fixed though by replacing the word “copy” with “mp3” in the created batch file - does anyone feel like creating a new front-end?).

Other Operating Systems

For those using other operating systems, there are many precompiled version of FFmpeg available, a little web searching and I'm sure you will find one for your environment.

I Can't Get it To Work!

When you are first setting up FFmpeg on your web server, I recommend that you turn on Verbose Logging in Media Gallery's System Options screen. This will give you much more information in your glFusion error.log file to help determine which set of command line options work best in your environment. What I have found through testing is that many times if FFmpeg does not support the input or output formats, it will simply crash and not give any return code. A little patience and diligence may be required to get it working properly.

Watermarking Image Media

If you choose, Media Gallery can automatically apply a watermark image to each image uploaded to your galleries. Media Gallery includes a Watermark Management system that allows you or your users (if they have ownership permissions on an album) to upload, delete and edit watermark images. To enter the Watermark Management, select Watermarks from the main Admin dropdown menu in the Album View.

When uploading watermarks, you have the option to specify if a watermark image should be public or private. If marked as public, any user who has ownership permissions on an album can use this image as a watermark. Private images can only be used by the user who uploaded them.

Albums can be configured to automatically watermark images when they are uploaded, or you can manually watermark images at anytime. To automatically have them watermarked, enable Auto Watermarking in the Album Edit screen.

To manually or selectively watermark imgaes, this is done in the Media Management screen. Select the images to watermark and choose Watermarking from the batch dropdown.

Once an image has been watermarked it cannot be watermarked again.

Image Resizing / Limits

Depending on the album configuration, Media Gallery may need to resize the uploaded image. If the image is larger than the resolution specified in the album configuration, Media Gallery will automatically resize the image to be at or below the size specified.

MP3 / OGG Processing

Media Gallery will apply some additional processing to MP3 and OGG audio files.

  • If the MP3 file has an embedded thumbnail, Media Gallery will extract the thumbnail image and use it as the attached thumbnail for the file.
  • Media Gallery will pull the artist, title, genre meta data from the MP3 or OGG audio file and populate the caption and description fields with this information.

Manage Media Items

This option allows you to perform batch moves or deletes on media in an album. Select Manage Media from the admin dropdown menu while viewing an album. It also allows you to manually sort the media in the album and add a caption to each item in the album. You can also select which image will be used as the 'album cover' for the album. This is the image that shows in the album list.

You can also edit the attributes and perform basic image edits by clicking on the image from the Media Management screen. This allows you to change the capture time, rotate the image, and modify the title, description, category or keywords.

You can also zoom in on any media item by selecting its icon, and a full view will be opened in a pop up window for viewing.

The following functions can be performed in the Manage Media Screen:

Batch Rotate ImagesSelect the images you wish to rotate by checking the Select Box to the left of the thumbnail. Select the direction to rotate the images from the batch drop down menu and then click the batch button.
Move media to new albumSelect the media items you wish to move by checking the Select Box to the left of the thumbnail. Choose the destination album from the album drop down list and click the move button.
Delete Media ItemsSelect the media items you wish to delete and then click the delete button. WARNING: Deletes are permanent, there is no method to recover the items.
Watermark ImagesIf you have enabled watermarking in the album attributes (and you have defined a watermark image to use), select the images you wish to have watermarked. Select Watermark from the batch drop down menu (Watermark will not appear if no watermark image has been defined for the album), and click the batch button.
Set Album CoverBy default, Media Gallery will use the newest image in the album as the album cover, but you can specify a specific image to use instead. Select the image you wish to use as the album cover by clicking the radio button to the right of the thumbnail (Cover Column). Be sure to press the save button to save your selection.
Reset Album CoverIf you had previously selected a specific image for the album cover but now want to return to using the Media Gallery default of showing the newest image, select the radio button labeled Reset Album Cover. Be sure to click the save button at the bottom to save your selection.
Sort Media ItemsYou can manually sort the order of the media items in your album. To the right of the thumbnail is a small entry box with a number in it. These numbers control the order the images are presented in the album. Larger numbers show first. You can change the sort order by changing the numbers in this box. Be sure to click the save button at the bottom to save your changes.
Include in slideshow autotagMedia Gallery's slideshow autotag is a very powerful feature, but it does have some limitations. If you mix portrait and landscape images in the slideshow autotag, it does not look as nice as having images of all the same size and orientation. You can select which images to include in the slideshow autotag by selecting the check box under the Include in SS column.

NOTE: This does not affect the album Slide Show.
Edit media items title, description, keywords and categoryYou can edit the title, description, add keywords and modify the category for each of the items in the album. Note: The category drop down will not appear if there are no categories defined.

You can also edit all the attributes of a media item by selecting the [Edit] link below each thumbnail.

Media Edit

You can edit the specific attributes of a media item by selecting the media's thumbnail from the Manage Media Item screen or from viewing the media item in Media Gallery.

This screen allows you to modify the general attributes of the item, such as orientation, title, description, etc. You can also attach a thumbnail to the media item. If a thumbnail is attached, that thumbnail image will be displayed when viewing the album thumbnails.

Reset Views

This will reset the views counter to 0.

Reset Rating

This will erase all existing rating data for this media item.

Original Filename

This is the original filename as it was uploaded to Media Gallery. This is only an informational field that can be used if you need to export your media items.

Attached Thumbnail

This option allows you to attach a thumbnail to the media item. The attached thumbnail will be displayed in the album index view. If you want to remove an existing attached thumbnail, simply uncheck the attached thumbnail checkbox.

You can replace an existing attached thumbnail by selecting the browse button and choosing a new image to upload.

Replace File

If you want to re-upload the file or upload a new file to take the place of an existing media item, select the Replace File checkbox and specify the new file in the entry field.

Alternate URL / Remote URL

The Alternate URL is used by autotags to provide a link to an alternative location instead of the media item view. Currently the fslideshow: autotag will use this field.

The Remote URL is used by either the Streaming FLV media type or an embedded video.


The media item's title.


The media item's description


Keywords for this media item to enhance the searching feature.


The category this media item should belong to.

Capture Time

This allows you to change the capture time stored in the database.

Don't forget to hit Save to store your modifications in the database or to upload the new thumbnail or replacement file.

Batch Caption Editor

If you use the Import via FTP or XP Publishing Wizard to upload items to your albums, you did not have an opportunity to enter a title or description for the items. The Batch Caption Editor is a streamlined interface designed to quickly and easily let you add/edit the titles and descriptions for your media items.

Sort Media Items

This option allows you to quickly sort all the media in an album based on Upload time or Capture Time (it will use the EXIF data if available in your media). Select which options you desire and click submit. All the media items for that album will be resorted.

glfusion/mediagallery/media.txt · Last modified: 2017/01/17 14:45 (external edit)

Page Tools