views:

179

answers:

1

Is anybody else using David Persson's media plugin for CakePHP? I'm struggling with setting up some features of the latest version. I'd like to set it up to make a UUID-based filename for uploaded images, but I'm not sure how to go about it.

I will fight with it some more, but I'm posting to find out if anybody here can tell me if the 1.3 is generally working or generally NOT working.

A: 

Finally got this (partially) working. The UUID filename stuff works when I place the following code in my Attachment model:

function transferTo($via, $from) {
    extract($from);
    $irregular = array(
        'image' => 'img',
        'text' => 'txt'
    );
    $name = Mime_Type::guessName($mimeType ? $mimeType : $file);
    if (isset($irregular[$name])) {
        $short = $irregular[$name];
    } else {
        $short = substr($name, 0, 3);
    }
    $path  = $short . DS;
    $path .= String::uuid();
    $path .= !empty($extension) ? '.' . strtolower($extension) : null;
    return $path;
}

I'm still having some trouble with other parts of the Media Helper, but the author posted some updates to his git repository today (Jul 17 2010).

the0ther
hey buddy .. did you get this plugin working ?
Harsha M V
i got pretty close, it did MOSTLY work out-of-the-box. in the end i switched to a different solution. i've noticed that the author has updated MediaHelper since then, so you might give it a try.
the0ther