• The Context: WP allows you to upload images, optionally creating a thumbnail of the image automagically.
    The Problem: The handy HTML it gives you after uploading an image does not include any reference to the thumbnail.
    The Solution: I modified wp-admin/upload.php so that, if you specify a thumbnail, it will find the size of the thumbnail and create HTML that displays the thumbnail image, wrapped with a link to the original image. It actually gives you two versions of the HTML – the first has the thumbnail code included, the second is the same HTML that the page used to generate.
    There’s a pseudo “diff” here:
    https://rm.bookdev.com/upload_with_thumbnail_code.phps
    I’d be very interested in feedback. I’ve tested it on my server, and it seems to work fine. (See it in action here.)

Viewing 15 replies - 16 through 30 (of 33 total)
  • Thread Starter monkinetic

    (@monkinetic)

    Hi all!
    I’ve posted a proper diff.
    upload_additions.diff found here.
    Use at your own risk.
    –Steve

    the thumbnail is usually located at https://yourserver.com/imagedir/thumb-pic.jpg where pic.jpg is the original images…
    abhi.

    Thread Starter monkinetic

    (@monkinetic)

    abhi,
    I did discover that eventually, but in 90% of the situations where I’m uploading images (as opposed to FTPing them as in the case of site graphics) it’s because I want to link to them from a blog post, and in 89% of those cases I want to link the thumbnail. I think I’m not alone.
    The patch here does not remove the original HTML code, it’s only adds another version to the returned code.

    As a latecomer, let me also say that this is an awesome and very useful contribution. Thanks!
    S.

    I was hoping for to find something like this! Nice!
    -PH

    I found one small typo in this version of upload.php. It writes its link like this: <img/>, so if you try to validate your page, you get end tag for that is not open. To fix this, just replace line 224 with this modified line:
    $piece_of_code = "This code will display the thumbnail, linked to the full-sized image:

    <img ". $sizes[3] ." src=&quot;". get_settings('fileupload_url') ."/$thumbfile&quot; alt=&quot;$imgdesc&quot; />"."

    "."This code will display the full-sized image:

    <img src=&quot;". get_settings('fileupload_url') ."/$img1_name&quot; alt=&quot;$imgdesc&quot; />";
    Best,
    S.

    I keep getting this error:
    Parse error: parse error, unexpected T_VARIABLE in /home/nobodys/public_html/blog/wp-admin/upload.php on line 207
    What should I do?
    Ill email you a copy of upload.php

    @daload > the same error was reported somewhere above… It seems it was caused by some characters (white space?) in the file. Try to check that everything is clean. HTH

    Anonymous

    Parse error: parse error, unexpected T_VARIABLE in /www/htdocs/v109938/blog/wp-admin/upload.php on line 207
    I am getting the same error, but I dont know what to clean up.. someone help please??? ??

    Anonymous

    thank you! I was looking for something like this!

    Anonymous

    worked great on my word press, but when i tried and install this into my friends wordpress I get the following error:
    Warning: chmod(): No such file or directory in /usr/home/******/public_html/wp-admin/upload.php on line 177
    Warning: getimagesize(/usr/home/******/public_html/images/thumb-abandonhouse10-13-04ss.jpg): failed to open stream: No such file or directory in /usr/home/******/public_html/wp-admin/upload.php on line 212
    weird… cause i can copy and paste my whole *working* upload.php into her space and she stll gets that error, works great on my wordpress. and we are using the same version…

    monkinetic,
    Great work – I’ve been using this on one of my sites for a while now and love it. Thanks!
    -Michael

    Over the weekend I upgraded from 1.2.1 to 1.2.2 and since then this peice of code does not work. Instead I’m getting upload errors of unsupported files even though I’m trying to upload .gif and .jpeg files.

    Any ideas what I need to change to make this work for 1.2.2?

    Thanks,

    -Michael

    ttt

    I would just like to point out the issue with validity since the code snippet in Strunk’s post is corrupted.

    What you need to do is to remove the / in the line mentioned by Strunk. You will find the correct / just after the title tag, and right before the starting img tag.

    As long as the code tag doesn’t like the php code it is impossible to post the correct code in here.

    Cheers

Viewing 15 replies - 16 through 30 (of 33 total)
  • The topic ‘Thumbnail HTML addition for upload.php’ is closed to new replies.