Support » Plugins » Correct code output for uploaded filtype

  • Hello all,
    has anyone managed to tweak the filosofo-old-style-upload.php plugin (in WP 2+) to display correct html for relevant filetype when uploading the file?

    I’m aware of the fact that this depends on the additional plugins used, but it would be nice to have the upload page display:

    if .jpg: <img src='url/file.jpg' alt='' />
    if .flv: <flv href="url/file.flv" />
    if .mp3: [audio:url/video.flv]
    if .mov: [ACT]url/[/ACT]

    so that users don’t have to change the code when pasting it in the writing interface. Currently WP outputs:
    <a href='url/file.flv' title='test'>test</a> (as a link) when I upload anything but jpg.

    Any suggestions?

    Hans Magnus

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello again,
    made a quick n’ dirty hack for the code output issue, at least when it comes to the plugins specified here. Thought maybe this could be helpful to someone.

    What it does, is simply checking the filetype, and outputs the appropriate tags needed for the plugin used.

    The new code goes in the filosofo-old-style-upload.php file, near line 280, where it originally says
    if ( ereg('image/',$img1_type) )
    $piece_of_code = "<img src='" . $this->get_settings('fileupload_url') ."/$img1_name' alt='$imgdesc' />";
    $piece_of_code = "<a href='". $this->get_settings('fileupload_url') . "/$img1_name' title='$imgdesc'>$imgdesc</a>";
    $piece_of_code = htmlspecialchars( $piece_of_code );

    I replaced the code above with:
    if (ereg('image/',$img1_type)) {
    $piece_of_code = "<img src='". $this->get_settings('fileupload_url')."/$img1_name' alt='$imgdesc' />";

    //flv video (use with FLV-WP by Roel Meurders):
    } elseif (ereg('application/octet-stream',$img1_type)) {
    $piece_of_code = "<flv href="".$this->get_settings('fileupload_url')."/$img1_name" />";
    $piece_of_code = htmlspecialchars( $piece_of_code );

    //quicktime video (use with Fallen Media Filter by Fallen):
    } elseif (ereg('video/quicktime',$img1_type)) {
    $piece_of_code = "[act]". $this->get_settings('fileupload_url')."/$img1_name,320,250[/act]";
    $piece_of_code = htmlspecialchars( $piece_of_code );

    // mp3 to flash player (use with Audio player by Martin Laine):
    } elseif (ereg('audio/mpeg',$img1_type)) {
    $piece_of_code = "[audio:". $this->get_settings('fileupload_url')."/$img1_name]";
    $piece_of_code = htmlspecialchars( $piece_of_code );

    // wmv embedding in post:
    } elseif (ereg('video/wmv',$img1_type)) {
    $piece_of_code = "<embed src='". $this->get_settings('fileupload_url')."/$img1_name' width=320 height=240 autostart=false controller=true loop=false ></embed>";
    $piece_of_code = htmlspecialchars( $piece_of_code );

    Hope this helps,
    Hans Magnus

    Escape the first ” after href= for flv files!
    For some reason this was not displayed in my previous post.

    Hans Magnus

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Correct code output for uploaded filtype’ is closed to new replies.