Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: How to identify media filetypes within plugin context  (Read 4796 times)

0 Members and 1 Guest are viewing this topic.

thejake420

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 79
  • Jakes Jokes - the largest joke site on the web
    • Jakes Jokes
How to identify media filetypes within plugin context
« on: July 29, 2006, 11:20:23 pm »

I am writing a plugin to provide code for "Show this video/picture on your site" functionality. I realize that this involves giving away the direct URL to the media within the code. (Which is fine for my purposes.)

The code itself is fairly simple... provide code with an IMG tag or an EMBED tag, and use {$normal_url} (already defined within the plugin) to provide the media URL.

However, since I have pictures and videos in the gallery, I will need to provide an IF (or switch, etc.) within codebase.php to provide the appropriate code, depending on whether it is a video or a picture. (Ideally, any other media type will simply not provide the "put this on your site" code on displayimage.php.)

That said, how can I have the plugin API determine the media type? For example, I know that {$pic_data['title']} will return the title. Is there a similar method for returning the media type? I'm sure I can find a bass-ackwards way of doing it, such as:

1. Get direct media URL and put it in a separate variable
2. Use PHP to Strip away everything except the last 3 characters of the URL (ie - the file extension, like gif, wmv, etc.)
Code: [Select]
echo substr('http://www.site.com/gallery/albums/albumname/filename.gif', -1, 3);
3. Process that value through a SWITCH/CASE statement
4. Based on the case, provide different code for each possibility.
5. Return that code in a cut & paste format to the user

That will work, but it will be quite inefficient. Surely there's some simpler method within the plugin API for determining whether the media type is a video or a picture...?


Jake
« Last Edit: August 04, 2006, 10:38:38 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: How to identify media filetypes within plugin context
« Reply #1 on: July 29, 2006, 11:39:35 pm »

Coppermine has some functions like is_image(), is_movie(), is_audio() and is_document() that you can use. Just give it the filename and it will tell you true or false.
Logged

thejake420

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 79
  • Jakes Jokes - the largest joke site on the web
    • Jakes Jokes
Re: How to identify media filetypes within plugin context
« Reply #2 on: July 29, 2006, 11:51:07 pm »

Nibbler -

Thanks as always for the fast and knowledgeable reply. I'll give those a whirl and see what I can come up with.


Jake

thejake420

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 79
  • Jakes Jokes - the largest joke site on the web
    • Jakes Jokes
Re: How to identify media filetypes within plugin context
« Reply #3 on: August 04, 2006, 10:37:35 pm »

Well, after fiddling with it for a while, I ended up doing it the hard way anyway. LOL here's a snippet that can be modified for whatever purpose someone may desire:

Code: [Select]
default :
// Set up variables to reflect necessary JS link from TagBlitz
$linkcode = "<a onclick=\"NewWindow(this.href,'TagBlitz','650','500','no','center');return false\" onfocus=\"this.blur()\" href=\"http://tagblitz.com/submit/?url={$url}?pos=-{$pic_data['pid']}&msurl={$url}?pos=-{$pic_data['pid']}&amp;title={$title}&keys={$keys}\" target=\"_blank\" TITLE=\"TagBlitz.com allows you to share a page on over 50 social bookmarking websites and services. No signup, no hassle!\"><font color=\"blue\" size=\"+1\">TagBlitz This Page</font></a>";
$buttoncode = "<a onclick=\"NewWindow(this.href,'TagBlitz','650','500','no','center');return false\" onfocus=\"this.blur()\" href=\"http://tagblitz.com/submit/?url={$url}?pos=-{$pic_data['pid']}&msurl={$url}?pos=-{$pic_data['pid']}&amp;title={$title}&keys={$keys}\" target=\"_blank\"><img src=\"http://www.tagblitz.com/img/button_tagblitzthis1.gif\" border=\"0\" ALT=\"TagBlitz.com allows you to share a page on over 50 social bookmarking websites and services. No signup, no hassle!\"></a>";
// Redefine download URL
$normal_url = get_pic_url($pic_data, 'normal');
$fullsized_url = get_pic_url($pic_data);
$thisfiletype = $fullsized_url;
$thisfiletype = substr("$thisfiletype", -3);
switch ($thisfiletype){
case "gif":
$leechcode = "<img src=\"http://www.jakesjokes.com/gallery/{$fullsized_url}\" alt=\"Over 50,000 free jokes, videos, pictures, and more at JakesJokes.com!\"><br><a title=\"Thousands of free jokes and videos\" href=\"http://www.jakesjokes.com\" target=\"_top\">Funny jokes, pictures, and videos</a>";
break;

// Other similar image case situations (jpg, png, bmp, etc.) removed for this post due to length.
case "swf":
$leechcode = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
        codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'
        width=\"320\" height=\"240\">
        <param name='movie' value=\"http://www.jakesjokes.com/gallery/{$fullsized_url}\">
        <param name='quality' value=\"high\">
        <param name='bgcolor' value='#FFFFFF'>
        <param name='loop' value=\"true\">
        <EMBED src=\"http://www.jakesjokes.com/gallery/{$fullsized_url}\" quality='high' bgcolor='#FFFFFF' width=\"320\"
        height=\"240\" loop=\"true\" type='application/x-shockwave-flash'
        pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
        </EMBED>
        </OBJECT>
<br><a title=\"Thousands of free jokes and videos\" href=\"http://www.jakesjokes.com\" target=\"_top\">Funny jokes, pictures, and videos</a>";
break;

// Other similar media case situations (avi, wmv, swf, mp3, etc.) removed from this post due to length.

Following the example above, similar case situations (avi, bmp, mp3, etc.) can easily be set up with the appropriate code to display the media on a remote site. (Bear in mind that this code endorses direct leeching off of my server. If you want to have a "passthrough" page such as remotevideo.php that does the actual display of the media, you'll need to set that up on your own, and pass the appropriate variables as needed.)


Jake

core212

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: How to identify media filetypes within plugin context
« Reply #4 on: January 12, 2007, 04:10:08 pm »

where do we install this? a little direction please?? thanks!
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 20 queries.