WordPress.org

Ready to get started?Download WordPress

Forums

WP-FileManager Tweak for Viewing Images (2 posts)

  1. nathanguadalupe
    Member
    Posted 3 years ago #

    I utilize WP-FileManager to upload an occasional small batch of image files (JPEG) onto my site, rather than running an FTP client.

    It's a great plugin, except that the view image feature malfunctioned whenever I attempted to view any graphics file. It would show a broken image icon instead.

    I like this plugin so much that I decided to tweak it so it works like it's supposed to...

    ** Go to "Editor" under "Plugins" menu and "WP-FileManager" from the drop-down list to edit it.
    ** Locate "wp-filemanager/incl/view.inc.php" from the list on the right-hand side of the browser and click on it, which will reveal its PHP syntax.
    ** Search/Find the following syntax...

    <img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/incl/libfile.php?path=".htmlentities(rawurlencode($path))."&filename=".htmlentities(rawurlencode($filename))."&action=view' width='$width' height='$height' alt='$StrImage'>";

    ** Disable using the appropriate PHP syntax or simply delete it.

    ** Add the following syntax in its place...

    $part_1 = 'http://'.$_SERVER['HTTP_HOST'].'/';
    $part_2 = $_GET['path'];
    $part_3 =  htmlentities(rawurlencode($filename));
    echo '<img src="'.$part_1.$part_2.$part_3.'" alt="'.$part_3.'" />';

    Click the "Update File" button and try viewing any image uploaded to your server.

    Quick note: The zoom in/out function doesn't work! I haven't found a fix for that yet.

  2. mn418
    Member
    Posted 3 years ago #

    What am I doing wrong I can't get images to view still with this tweak? Thank you so much!

    <?php

    if (!@include_once(WP_CONTENT_DIR . "/plugins/wp-filemanager/incl/auth.inc.php"))
    include_once(WP_CONTENT_DIR . "/plugins/wp-filemanager/incl/auth.inc.php");

    if ($AllowView && isset($_GET['filename']))
    {
    $filename = stripslashes($_GET['filename']);

    print "<table class='index' width=800 cellpadding=0 cellspacing=0>";
    print "<tr>";
    print "<td class='iheadline' height=21>";
    print "<font class='iheadline'> $StrViewing \"".htmlentities($filename)."\" $StrAt ".$_GET['size']."%</font>";
    print "</td>";
    print "<td class='iheadline' align='right' height=21>";
    print "<font class='iheadline'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/back.gif' border=0 alt='$StrBack'></font>";
    print "</td>";
    print "</tr>";
    print "<tr>";
    print "<td valign='top' colspan=2>";

    print "<center>
    ";

    if (is_file($home_directory.$path.$filename) && is_viewable_file($filename))
    {
    $image_info = GetImageSize($home_directory.$path.$filename);
    $size = $_GET['size'];
    $zoom_in = $ZoomArray[get_current_zoom_level($size, 1)];
    $zoom_out = $ZoomArray[get_current_zoom_level($size, -1)];
    $width = $image_info[0] * $size / 100;
    $height = $image_info[1] * $size / 100;

    $files = array();
    if ($open = opendir($home_directory.$path))
    {
    while ($file = readdir($open))
    if (is_file($home_directory.$path.$file) && is_viewable_file($file))
    $files[] = $file;
    closedir($open);
    sort($files);

    if (count($files)>1)
    {
    for($i=0;$files[$i]!=$filename;$i++);
    if ($i==0) $prev = $files[$i+count($files)-1];
    else $prev = $files[$i-1];
    if ($i==(count($files)-1)) $next = $files[$i-count($files)+1];
    else $next = $files[$i+1];
    }
    else
    {
    $prev = $filename;
    $next = $filename;
    }
    }

    print "<table class='menu' cellpadding=2 cellspacing=0>";
    print "<tr>";
    print "<td align='center' valign='bottom'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/plus.gif' width=11 height=11 border=0 alt='$StrZoomIn'> $StrZoomIn</td>";
    print "<td align='center' valign='bottom'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/minus.gif' width=11 height=11 border=0 alt='$StrZoomOut'> $StrZoomOut</td>";
    print "<td align='center' valign='bottom'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/original.gif' width=11 height=11 border=0 alt='$StrOriginalSize'> $StrOriginalSize</td>";
    print "<td align='center' valign='bottom'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/previous.gif' width=11 height=11 border=0 alt='$StrPrevious'> $StrPrevious</td>";
    print "<td align='center' valign='bottom'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/next.gif' width=11 height=11 border=0 alt='$StrNext'> $StrNext</td>";
    print "</tr>";
    print "</table>
    ";
    $part_1 = 'http://'.$_SERVER['HTTP_HOST'].'/';
    $part_2 = $_GET['path'];
    $part_3 = htmlentities(rawurlencode($filename));
    echo '<img src="'.$part_1.$part_2.$part_3.'" alt="'.$part_3.'" />'
    ;
    }
    else
    {
    print "<font color='#CC0000'>$StrViewFail</font>

    ";
    print "$StrViewFailHelp";
    }

    print "

    </center>";

    print "</td>";
    print "</tr>";
    print "</table>";

    print "<input type='hidden' name='path' value=\"".htmlentities($path)."\">";
    }
    else
    print "<font color='#CC0000'>$StrAccessDenied</font>";

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic