srs81 / CakePHP-AjaxMultiUpload

CakePHP 2 plugin to allow for easy multi-file upload with AJAX
Other
65 stars 32 forks source link

Show the image itself #13

Closed andranos closed 12 years ago

andranos commented 12 years ago

Hi there,

first of all, really great plugin, working perfectly I just wanted to ask, is there any way to show the picture thumbnail if i chose to upload a picture rather than showing the name of file?

Any help would be greatly appreciated

srs81 commented 12 years ago

Yeah, this should be pretty straightforward. in the /View/Helper/UploadHelper.php, look for line 37:

$str .= "<img src='" . Router::url("/") . "ajax_multi_upload/img/fileicons/$type.png' /> ";

You can change this to:

if (in_array($type, array("png", "jpg", "jpeg"))) {
    $str .= "<img src='$url'/> ";
} else {
    $str .= "<img src='" . Router::url("/") . "ajax_multi_upload/img/fileicons/$type.png' /> ";
}

If you don't want to modify the plugin, you can use the listing() function and create your own view() function to replace it.

I've toyed with making this change to the core, but don't want to in case some people load large image files.

Let me know if this helps!

andranos commented 12 years ago

Yep it's working perfectly and as you said, the image shown is the actual size (i think) Is there any way to show it as a thumbnail or make it smaller (400x300 or something like that)

srs81 commented 12 years ago

The easiest way is:

$str .= "<img src='$url'/ height='300'> ";

If you really want to scale the image down and create thumbnails, you'll have to generate them "offline". That's a bit of work though...

andranos commented 12 years ago

Working perfectly, thank you for your assist