The recommended method to install Media Hosting, is simply using your target website marketplace page. However, if you wish not to use concrete5 internal feature, you can follow the next instructions :
After installing Media Hosting (either through downloading or preferably directly through your concrete5 website interface), you will be provided with 3 blocks :
Media Hosting will also install a dashboard menu, and 5 files attributes :
Media Hosting finally comes with 2 automated jobs :
(see the Jobs section for more details)
File Embed Block comes with an image block. This block lets you embed an file in various ways within any page area, then record viewing statistics of that file. To add an image into your page, edit the page and add an instance of the File Embed Block to your page. The add dialog will ask you to select the type of embedding and the file to embed.
The following embedding types are available :
The audio and video embed type support multiple sources. To add a source to your media embedding, click on the
button (only displayed for audio and video embeds).The
will let you specify exactly how the embed will behave and be shown. Options depends on the type of embed selected.The
tab will let you choose the size of the image, and as well as statistics recording options:The
tab let you add a thumbnail to the embed, and specify the thumbnail dimensions.The
tab will let you choose what behavior to apply if the image (or thumbnail) is clicked :Here is a description of the choices available :
Image Hosting Block comes with an image block. This block lets you show an image in various way within any page area, then record viewing statistics of that image. To add an image into your page, edit the page and add an instance of the Image Hosting Block to your page. The add dialog will ask you to select an image to show and specify an optional alt attribute :
The
tab will let you choose the size of the image, and as well as statistics recording options:The
tab let you specify how the image is seen as a thumbnail.When the image is seen as a thumbnail, you have the choice to record the view statistics on the thumbnail view, and or on the image. In the latter case, the image view statistic will only be recorded if the image is shown in a lightbox overlay or if the image is linked to the click behavior.
The
tab will let you choose what behavior to apply if the image (or thumbnail) is clicked :Here is a description of the choices available :
In thumbnail mode and if the image is set to link to either the image itself or open in lightbox, the target image will be opened at the size defined in the Resize image option is activated), or full sized if not.
size (in case the
In normal mode, (as opposed to thumbnail mode), if the click behavior is set to Link to Image, the image will be opened full size.
Uploader queue are the way Media Hosting manages jobs to be run on upload. To upload an image, you need first to create an uploader.
To create an uploader, go to the dashboard uploaders page then click on the
button:Each uploader must have a name. Each uploader can have a unique key, this key is used to upload automatically a file using the uploader page (see advanced an developer section of this documentation).
Each uploader performs specific tasks upon file upload based on the options selected :
Prefix Add a prefix to the shared path (when recording the sharing path). This prefix will be the first prepended to the recorded path (before the path given to the page and before the block prefix if the upload is coming from the upload form block).
HTTP Redirect Sets the http rediect attribute by prefixing a custom content to the path computed for this file. This enables you to actually serve the file from a different location (for instance from a CDN).
Record sharing path record the sharing path of uploaded files. The path can be either set directly in the uploader page parameters or via the upload block form.
Share uploaded files automatically share uploaded files (set the corresponding file attribute to Yes )
Record view stats of uploaded files automatically enable stat recording for uploaded files. (set the corresponding file attribute).
Automatically add uploaded files to sets, if enabled, will add the uploaded files to the file sets recorded. To add a fileset to the list, select it in the file set list, then click add. To remove a fileset, click on the x aside the fileset name.
Create file set based on path elements, if enabled, the path will be split in elements and for each element a file set will be created. For example, if the final path of an uploaded file is a/b/c/file.png, then filesets "a", "b", and "c" will be created and the uploaded file will be added to all these file sets.
Force owner, if enabled, the owner of the file will be changed to the "Upload As" option
Set Http Redirect, if enabled, the http redirect attribute will be set automatically by adding the path to the Http Redirect Prefix in the Http redirect option.
Media Hosting comes with the Media Hosting Upload Form block. This block will let your users upload a file through an uploader directly from a page. To do so, just add the block into your page. The following options will be available:
Here is an example of the block in page:
Media Hosting includes a dashboard page. From this page, you will be able to manage all existing shared files, as well as share new files. This page works exactly in the same way the File Manager does, except it adds some new menus to the context menu and to the operation list
The
page gives you the following choice of operation on single elements and files selections:By default, the Advanced Search menu located on the top right part of the window, then click on Show not shared files checkbox, and finally refresh the list by clicking button.
manager will only show shared files (either through an image block, file embed block, or through a share path attribute), if you want to see not shared files, open the
Finally, You can directly upload and share a file using the built-in
button.
The afore mentioned interfaces are highlighted on the next screenshot:
You can share a file through a number of ways :
The recommended way of sharing an existing file is either using the image block/file embed block to show it on your website, or using the
dashboard page. The next screenshot show an highlight of that page :All the statistics are available in the
dashboard page.
By default, the statistics page will show the aggregated results of all existing view log stat. Five reports are computed :
You can collapse a report by clicking on the report heading itself. Each report can be filtered to only include the most relevant results by changing the limit to value and then clicking on button.
Each report have 5 panes :
Each pane will include a pie chart and a bar chart to show the repartition in the concerned time period. All interval constraint panes (year/month/24 hours/3 hours) will additionally show an evolution of that repartition with an area chart and a line chart.
Finally you can filter the statistics with various filters:
The afore mentioned interfaces are highlighted in the next screenshot :
The
dashboard page will allow you to delete a part of or all the view statistics. The same filters used on the page can be used on the settings page to select the statistics as well.
By default the deletion interface is hidden, to show it, click on the
button in the dashboard page.
The following screenshot shows the deletion options :
The upload page includes several areas. You can edit and add blocks to this page by either visiting directly the page at http://yoursite.com/gnt_image_hosting/upload (or to your custom upload page if you created one), or by choosing it in the Full site map. By default, this page is excluded from navigation.
The following screenshot shows the upload page in edit mode :
The page contains the following areas
Beware that this page is only shown when using the upload block in non ajax mode.
Media Hosting comes with an HTTP redirect ability. When used appropriately, you can actually manage your media files on your server but serve them from another server, e.g.: a CDN (and still collect view stats on them), here is how:
To make this work, you will have to create a directory structure that matches your path structure on the CDN. For instance, if you have a file that is shared under /my/share/path/thefile.mp4, and that your CDN base url is http://www.mycdn.com/pub/, then you must make your file accessible through http://www.mycdm.com/pub/my/share/path/thefile.mp4.
Once this is done, just set the HTTP redirect attribute to http://www.mycdn.com/pub. At this point, the stremer and the blocks (file or image block), will record the view stats, but take the file from the location you specified.
For more automation, the attribute can be automatically set in the uploader queue.
At the moment, only files can be served using HTTP redirect, not thumbnails, if you need this feature, please contact us directly.
Media Hosting allows you to use your own custom stream/upload page.
For instance, if you wanted to have your own custom url, say, http://yoursite.com/oh/streamit for the streamer or uploader instead of the default http://yoursite.com/gnt_image_hosting/stream or http://yoursite.com/gnt_image_hosting/upload :
Media Hosting will then create a page at the desired location and use it as a stream or upload page based on your choice.
Media Hosting stream page will let you manipulate images (if streaming images) as well as record other statistics information along with streaming the corresponding image. Here is the list of supported parameters :
In case both path and bID parameters are omitted, the first parameter name will be considered to be the path.
Examples:
Will stream the image name /my/path/file.png, resize the image to 640x480 (no cropping), and record the keywords foo, bar, and turtle along with the view stat (if the corresponding path is setup to record stats).
The preceding url was equivalent to :
Media Hosting is designed to let you upload files directly from another program. The uploader page located at http://yoursite.com/gnt_image_hosting/upload can be very simply commanded from any http request.
To upload a file, you will need to create an uploader (see preceding documentation), then record its key (say UPLOADERKEY). Then issue a POST or GET request to the uploader page to upload it (although parameters can be read from GET for convinience, the file will need to be posted).
Here are the available parameters :
For example, posting a file to the following url :
Will upload the file, sets its shared path to /some/where/my_image.png and disable recording view stat for this uploaded file.
In case a file with the same sharing path is found, that file is overwritten. Actually, the MD5sum of the new uploaded file is compared to the old one, and the new one only gets updated if the MD5sum mismatches, so it is safe to upload twice the same file, nothing will actually happen.
By default, this addon uses HostIP.info online service to lookup IP locations. This API does not give 100% results and sometimes does not know about the IP location. Fortunately, updates to that API is done on a daily basis, which means that an Unknown IP yesterday may not be unknown anymore today! Media Hosting provides two automated jobs to take advantage of those updates :
By running the Fix missing view location stats once in a while (or yet better, by automating it), your statistics will get refined every time with the latest Hostip.info data.
As mentioned, by default this addon uses HostIP.org online service to lookup IP locations. You can change this by first installing other IP locators engine (for example look at the Maxmind IP GeoLoc addon), and then changing the default engine in the settings page.
This is for developers only, but what if you wanted to have your own custom url for the streamer or uploader instead of the default http://yoursite.com/gnt_image_hosting/stream or http://yoursite.com/gnt_image_hosting/upload for instance?
Well that is actually pretty simple, create a single page where you want it, at for instance : http://yoursite.com/this/is/where/I/want/my/streamer and include this into your page code :
include( DIR_PACKAGES . "/gnt_image_hosting/single_pages/gnt_image_hosting/stream.php" );
or (for the uploader) :
include( DIR_PACKAGES . "/gnt_image_hosting/single_pages/gnt_image_hosting/upload.php" );
Those two single pages actually don't have any controller so you can safely include them directly. If you want then Media Hosting to use your custom page internally, go to the page and select your page as Stream or Upload Page. Media Hosting can only use one stream page or one upload page by default, but multiple pages can exist separately (you can use them directly just fine). Additionally, uou can directly create a sample page from the page in the dashboard.
To programmatically record view stats onto a file, you will need to retrieve the HostedMedia object associated to the file and record the view log. Assuming that $fID holds the file ID :
Loader::model( 'hostedmedia', 'gnt_image_hosting'); HostedMedia::getByID($fID)->recordView();
That code will automatically check if the Record Stats attribute is set onto that file before recording the stats. You can find more information on the API by having a look at models/hostedmedia.php class.
If, like me, you are a concrete5 addon developer, you already noticed you can not add images into your marketplace addon documentation pages since c5 website will not host them for you. Well, I initially built this addon for that reason.
Simply speaking, here is the workflow I would recommend for you :
And that's it!
This can be simply achieved with the following simple makefile script for instance:
BUILD=build DOCDIR=doc LOCAL=$(BUILD)/$(DOC)/local REAL=$(BUILD)/$(DOC)/real UPLOADERKEY=283987198778877287 BASEURL=http://www.mysite.com HANDLE=my_package_handle UPLOAD=$(BASEURL)/gnt_image_hosting/upload STREAM=$(BASEURL)/gnt_image_hosting/stream build_doc_local: mkdir -p $(LOCAL) cp $(DOCDIR)/*png $(LOCAL)/ ( for $$x in $(DOCDIR)/*.html; do cat $$x | sed -e "s/PREFIX//" > $(LOCAL)/$$x ) build_doc_real: mkdir -p $(REAL) # uploading files ( \ cd $(DOCDIR) ;\ for $$x in *png; do \ do curl -F path=$(HANDLE)/$$x -F file=@$$x -F key=$(UPLOADERKEY) $(UPLOAD); done ; \ ) #replacing image links ( \ for $$x in $(DOCDIR)/*.html; do \ base=$$(basename $$x); \ cat $$x | sed -e "s,PREFIX,$(STREAM)?$(HANDLE)/$$base," > $(REAL)/$$x ; \ done; \ )
I hope this will help concrete5 developers to build awesome documentations for their addons.
As a bonus, you will then be able to record view statistics on the images you embed in your documentation.
Media Hosting can use an external IP locator service either from your site override, or onto a package you are creating. To add an ip locator in your site override, create the following directory:
your_site/blocks/gnt_image_hosting/models/iplocators
To add an ip locator to a package you are creating, create the following directory :
your_package/models/gnt_image_hosting/iplocators
Within the created directory, create a file with the named after the ip locator class you want, for instance my_service.php. Now in that file, you will need to define a class inheriting from IPLocator named after your file name (camel-cased) and suffixed with Locator. Following our example, if the file is named my_service.php then the class should be MyServiceLocator
Here is what such a class could look like :
<?php defined('C5_EXECUTE') or die('Access Denied.'); class MyServiceLocator extends IPLocator { public function name() { return t("My Service IP locator" ); } public function isFunctionnal() { return true; } public function getStandardCountryName($ip) { // return a string "Country (ISO CODE)" for that ip // return null if not known return "France (FR)"; } public function getCityName($ip) { // return the name of the city or null if not known return "Paris"; } } // vim: set noexpandtab ts=4 :
In order to override an existing IP Locator engine, just copy the file in your site override your_site/blocks/gnt_image_hosting/models/iplocators directory and the ip locator will be auto-magically overridden by your new file.
If you need any assistance regarding this addon, please use the support forum directly.
In case you need a new feature, or anything else, feel free to contact us threw concrete5 PM system, or contact us directly.