(SOLVED) Forcing Movies to Download Instead of Play In Browser

KeblerelfKC

Joined: 2007-08-14
Posts: 8
Posted: Mon, 2007-08-20 18:23

I'm starting to place some home movies and other videos in my gallery and was wondering if there was some way that I could set it so when a user clicks on the thumbnail for a video it pops up a Save/Open box for them to download it instead of moving them to a new page to view the video within the browser?

The only solution I've found so far for allowing the download of videos is to add the Cart and Download Zip modules, having the person add the video to their cart, viewing the cart and then downloading the cart items as a zip. Since my site is mainly being used by very non-technical family members I'd like to simplify the process as much as possible.

Quote:
Gallery version = 2.2.2 core 1.2.0.4
PHP version = 5.2.2 cgi-fcgi
Webserver = Apache/2.0.54 (Unix) PHP/4.4.7 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
Database = mysqli 5.0.24a-standard-log, lock.system=database
Toolkits = ArchiveUpload, Exif, Ffmpeg, NetPBM, Gd, ImageMagick, LinkItemToolkit, Thumbnail
Acceleration = none, none
Operating system = Linux lifesaver 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686
Default theme = floatrix
gettext = enabled
Locale = en_US
Browser = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)
Rows in GalleryAccessMap table = 24
Rows in GalleryAccessSubscriberMap table = 971
Rows in GalleryUser table = 3
Rows in GalleryItem table = 944
Rows in GalleryAlbumItem table = 83
Rows in GalleryCacheMap table = 0

 
thumb
thumb's picture

Joined: 2004-05-26
Posts: 238
Posted: Mon, 2007-08-20 19:00

You could probably accomplish this by editing your selected theme. In album templates you could change viewItem links to download links for movie items. You'll need to consider your family member's stock browser configuration as it relates to the movie file type you're posting.

See http://codex.gallery2.org/Gallery2:Themes:How_to_Edit_an_Existing_Theme for information on editing theme templates.

http://2tbsp.com

 
KeblerelfKC

Joined: 2007-08-14
Posts: 8
Posted: Mon, 2007-08-20 19:34

I unfortunately don't know a whole lot about coding so I think I might need some help here. However, you've already answered another question I had which was "How to remove the text 'Album: ' that appears before album names. So thanks for that. :)

Anyway, I'm looking at a copy of the album.tpl for the floatrix theme and I'm assuming this part is what I would need to modify correct?

Quote:
<div id="gsThumbMatrix">
{foreach from=$theme.children item=child}
<div class="{if $child.canContainChildren}giAlbumCell gcBackground1{else}giItemCell{/if}" style="width: {$theme.params.columnWidth}px; height: {$theme.params.rowHeight}px;">

{if ($child.canContainChildren || $child.entityType == 'GalleryLinkItem')}
{assign var=frameType value="albumFrame"}
{capture assign=linkUrl}{g->url arg1="view=core.ShowItem"
arg2="itemId=`$child.id`"}{/capture}
{else}
{assign var=frameType value="itemFrame"}
{capture assign=linkUrl}{g->url params=$theme.pageUrl
arg1="itemId=`$child.id`"}{/capture}
{/if}

{strip}
{if isset($theme.params.$frameType) && isset($child.thumbnail)}
{g->container type="imageframe.ImageFrame" frame=$theme.params.$frameType
width=$child.thumbnail.width height=$child.thumbnail.height}
<a href="{$linkUrl}">
{g->image id="%ID%" item=$child image=$child.thumbnail
class="%CLASS% giThumbnail"}
</a>
{/g->container}
{elseif isset($child.thumbnail)}
<a href="{$linkUrl}">
{g->image item=$child image=$child.thumbnail class="giThumbnail"}
</a>
{else}
<a href="{$linkUrl}" class="giMissingThumbnail">
{g->text text="no thumbnail"}
</a>
{/if}
{/strip}

Where and how would I add the check to see if it's a movie item versus picture item? Would you mind kind of holding my hand on this one? hehe

Thanks in advance for any help you can provide. :)

 
KeblerelfKC

Joined: 2007-08-14
Posts: 8
Posted: Mon, 2007-08-20 19:40

Actually something I just thought of that might work even better and possibly might be even easier in terms of modifications is to just add a "Download" link that appears under every item be it a movie or a picture. I've actually had one of my users ask about that so this could kill two birds with one stone and still leave the option open to viewing the movies in the browser if they really wanted to.

How would I go about adding just that download link so it shows up like right below the thumbnail?

 
KeblerelfKC

Joined: 2007-08-14
Posts: 8
Posted: Mon, 2007-08-20 20:50

I've been messing around and have the link showing up now by adding the following line:

Quote:
<p class="gbBlock"><a href="{$child.pathComponent}">Download</a></p>

Two problems though. If you click on the link it just takes you to the standard view page just like if you clicked on the thumbnail. Also, if you right click on the link and do "Save Target As..." it saves an htm file instead of the image/movie file.

Any ideas?

 
KeblerelfKC

Joined: 2007-08-14
Posts: 8
Posted: Mon, 2007-08-20 23:34

I found a separate PHP script that will force file downloads. I modified it to extract the path of the file partially from hard coded values and partially from the referring URL. Anyway, it seems to be doing what I want it to do now. :)

 
thumb
thumb's picture

Joined: 2004-05-26
Posts: 238
Posted: Tue, 2007-08-21 20:19

Way to go and thanks for sharing your steps with everyone. If you can, add a link to the PHP script you found.

http://2tbsp.com