Introduction

Before
Before

I decided to expand my art gallery to include some FLVs and MP3s and found that my trusty Zenpressed plugin doesn't check if the file is an FLV or an MP3, and instead just tries to embed the mp3/flv as a thumbnail.

I looked around for a few different plugins that would recognise the multimedia formats, but none of them were as awesome as Zenpressed. Zenpressed hadn't been updated since the dawn of time so I didn't expect to find any help from their website.

Instead I dove in to the code and created a small hack for multimedia formats.

After
After

It seemed fairly simple enough. At the moment, the plugin takes the image url and uses it as a thumbnail.
For multimedia formats, Zenphoto requires an image to be made with the same filename as the multimedia file, uploaded to the same folder as the file.
For example, the thumbnail for mymovie.flv would be mymovie.jpg, so all I really needed to do was put a script in that removed the file extension and add ".jpg" to the end of the url.

And guess what? It really was that simple.

Installation

  1. Navigate to your [wordpress install directory]/wp-includes/plugins folder.
    Download your zenpressed.php file, create another copy of it and back it up somewhere safe just to be careful.
  2. Open up the zenpressed.php file in your favourite code editor.
  3. Find line number 75
    The line below it should start with:
    76
    77
    
    // Output
    $c =

    This is where the file starts it's output, we want to modify the filename URL before then, so on line 75 enter the following code:
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    
    // Multimedia Replacement mod by dBaines.com - Replaces image.flv with image.jpg
        // Get last three characters from filename
        $se = substr($s,-3);
        // Check if FLV or MP3
        if ($se == "flv" or $se == "mp3") {
            // Remove last 3 characters from image filename, "flv"
            $s = substr($s, 0, -3);
            // Add "jpg" to filename
            $s.="jpg";
        }
    // End Multimedia Replacement mod by dBaines.com

    WARNING: If you have modified your zenpressed.php file in any way or have downloaded a fork or pre-modified version of it, then your line number will possibly not match. Please make sure you have the official version to make sure you are putting the code in the right place.

    If you have a modified version of zenpressed you might not be sure what line to put this code on.
    It goes in the zenpressed_showphoto function, under the "generate data" section and before the "output" section.

  4. Save and reupload the file and you're good to go!