How do I replace flash Avatar Uploader with simple Upload-a-File?
Permalink
Hi!
I would like to get rid of that flash avatar loader.
In my opinion it's pretty hard to understand for a user, and I'm unable to translate its buttons to Russian.
Anyway, I suppose there should be a way to replace it with simple file upload.
Have any ideas, how do I do that?
I would like to get rid of that flash avatar loader.
In my opinion it's pretty hard to understand for a user, and I'm unable to translate its buttons to Russian.
Anyway, I suppose there should be a way to replace it with simple file upload.
Have any ideas, how do I do that?
Hey there!
I solved the problem for myself and would post the code in couple hours. Wait for it :)
I solved the problem for myself and would post the code in couple hours. Wait for it :)
It would be great! :-)
So, here's how you do it (at least, how I did it :)
First, here's what you need:
* Convert, an ImageMagick utility. I use it to resize images to proper size and convert those to jpg.
My site is hosted on linux VPS and I have it in a repository. If you're running windows -- look for it, it is probably available.
* Proper permissions: make sure the user, which runs php (in my case -- www-data) has proper folder permissions.
Specifically, check that it has read and write permissions to /files/tmp and /files/avatars folders.
It may also be good to run 'set' from within php just to know if everything else is fine (like, php has permission to run convert itself :) -- print(exec('set'));
Second, alter files:
* in /concrete/controllers/profile/avatar.php put this code:
* in /concrete/single_pages/profile/avatar.php:
replace <div id="profile-avatar"> contents with this:
You don't probably want to mess with concrete core files, so you should create separate files outside /concrete directory.
But I didn't. Yet :)
If you have any questions or know how to do it better -- be sure to tell.
First, here's what you need:
* Convert, an ImageMagick utility. I use it to resize images to proper size and convert those to jpg.
My site is hosted on linux VPS and I have it in a repository. If you're running windows -- look for it, it is probably available.
* Proper permissions: make sure the user, which runs php (in my case -- www-data) has proper folder permissions.
Specifically, check that it has read and write permissions to /files/tmp and /files/avatars folders.
It may also be good to run 'set' from within php just to know if everything else is fine (like, php has permission to run convert itself :) -- print(exec('set'));
Second, alter files:
* in /concrete/controllers/profile/avatar.php put this code:
public function saveImage() { // This little part checks if user is logged in and alse gets us an user interface object to work with later. $user = new User(); $ui = $this->get('ui'); if (!is_object($ui) || $ui->getUserID() < 1) { return false; } // That's where we start working with files. // First, check that filetype is gif, jpg or png (to know that we're getting an image). And check if it's not too big (less than 20000 bytes) if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/png") && ($_FILES["file"]["size"] < 20000)) { // if theres an error -- drop a message and quit. if ($_FILES["file"]["error"] > 0) { $this->set("error", "There was an error uploading the image. Try again or tell the admin, he'll fix it.");
Viewing 15 lines of 44 lines. View entire code block.
* in /concrete/single_pages/profile/avatar.php:
replace <div id="profile-avatar"> contents with this:
<p id="avatar_error"><?php print $error;?></p> <?php $form = Loader::helper(form); ?> <form action="<?php print $this->action("saveImage");?>" method="post" enctype="multipart/form-data"> <p><?php print $form->label("file", "Image:"); ?></p> <p><?php print $form->file("file"); ?></p> <p><?php print $form->submit("submit_avatar_file", "Gimme new avatar →"); ?></p> </form>
You don't probably want to mess with concrete core files, so you should create separate files outside /concrete directory.
But I didn't. Yet :)
If you have any questions or know how to do it better -- be sure to tell.
Thanks a lot.
I think I will give a try to integrate it with this script:http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/...
Should be possible to do that in 2 phases (first upload to temp, then create thumb and move to avatar folder).
I will post here the code if I succeed.
I think I will give a try to integrate it with this script:http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/...
Should be possible to do that in 2 phases (first upload to temp, then create thumb and move to avatar folder).
I will post here the code if I succeed.
Yeah, that feature sounds cool: same as that flash uploader, but without unnecessary flash :)
Tell me if it's gonna work out.
Tell me if it's gonna work out.
Getting error Warning: shell_exec() has been disabled for security reasons
Or how to translate it into other language. We create a community portal based on C5 and we need this functionality in Polish language.