WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Correct code output for uploaded filtype (3 posts)

  1. Hans Magnus Mikalsen Nedreberg
    Member
    Posted 8 years ago #

    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/file.mov[/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?

    Thanks,
    Hans Magnus

  2. Hans Magnus Mikalsen Nedreberg
    Member
    Posted 8 years ago #

    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' />";
    else
    $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:
    //image:
    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

  3. Hans Magnus Mikalsen Nedreberg
    Member
    Posted 8 years ago #

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

    Hans Magnus

Topic Closed

This topic has been closed to new replies.

About this Topic