Page 1 of 1

Remove image button

Posted: Tue Dec 15, 2009 4:27 am
by montanaflynn
A client added some images to categories and wants to remove them completely, but their is no option for that. How about adding an remove image button?

Re: Remove image button

Posted: Wed Dec 16, 2009 3:26 am
by Qphoria
I second this... a nice small x next to the image to remove would be good. or use the do not enter sign that the option remove button uses

Re: Remove image button

Posted: Thu Dec 17, 2009 12:45 pm
by montanaflynn
My idea would be to remove the image input in the "data" tab from the product section and into the image tab where it makes more sense to be. If more than one image is uploaded a default labeled checkbox should be added for users to select the default image and the remainder would be Additional images. That would be more logical to most people.

Also the order of tabs could be changed to put images after data and be renamed like this:

General
Data
Images
Options
Discounts
Specials

Re: Remove image button

Posted: Thu Dec 17, 2009 1:20 pm
by fido-x

Re: Remove image button

Posted: Thu Dec 17, 2009 1:59 pm
by montanaflynn
Thanks fido, but I am looking for opencart to make these changes in later releases. If you have any comments or suggestions they would be appreciated.

Re: Remove image button

Posted: Thu Dec 17, 2009 6:58 pm
by fido-x
montanaflynn wrote:Thanks fido, but I am looking for opencart to make these changes in later releases. If you have any comments or suggestions they would be appreciated.
I don't think my comments on this issue would be appreciated, but here they are anyway.

Currently, the only way to remove images is to do it via FTP. The "Image Manager" I pointed you to, allows you to do it from the OpenCart admin. It is available for versions 1.3.2 and 1.3.4. Maybe you should ask your client if they want to wait for the next release when Daniel may or may not include some means of managing images.

Re: Remove image button

Posted: Thu Dec 17, 2009 7:28 pm
by i2Paq
fido-x wrote:
montanaflynn wrote:Thanks fido, but I am looking for opencart to make these changes in later releases. If you have any comments or suggestions they would be appreciated.
I don't think my comments on this issue would be appreciated, but here they are anyway.
Why not, it is up to people to buy anything if they need it and you provide something usefull so why not point towards it.

You are not the only one ;)

Re: Remove image button

Posted: Sun Sep 26, 2010 11:14 pm
by burrito
Qphoria wrote:I second this... a nice small x next to the image to remove would be good. or use the do not enter sign that the option remove button uses
I'm actually looking into this now, my initial idea was to create a dbase-routine to remove the image from the dbase when the button is clicked.
But now that I'm thinking about it, all it needs to do is go back to the original state :
- empty hidden field
- default preview because hidden field is empty

My javascript just isn't good enough to solve this (I don't know any javascript for that matter ;) )

This is what I have so far:
behind the image preview I added:

Code: Select all

<span class="remove" onclick="image_remove('image', 'preview');">&nbsp;</span>
And after the javascript function for the image manager I added:

Code: Select all

<script type="text/javascript"><!--
function image_remove(field, preview) {
			$('#' + field).replaceWith('');
			$('#' + preview).replaceWith('<img src="<?php echo $no_image; ?>" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />');
					
				};
//--></script>
the $no_image is added to the controller as well to link to the right image and size.

Now the page still works :P and the remove button is shown... just doesn't do what I want it to do, I made the hidden image field temporarily visible for a better understanding of whats happening.

It's actually pretty straight forward ... the value of the field "image" needs to be replaced by nothing and the preview relaced by <img src="<?php echo $no_image; ?>" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />

anyone here to finalize this?

Re: Remove image button

Posted: Mon Sep 27, 2010 3:05 am
by burrito
OK, I have it working now.... it wasnt for a few hours and I repasted some code and now it works... still don't know what I have changed... but who cares :P

haha

so, here it is, how to add the button:
next to your preview image (or whereever you want the remove button) add:

Code: Select all

<span class="remove" onclick="image_remove('image', 'preview');">&nbsp;</span>
and right after the script for image_upload, add:

Code: Select all

<script type="text/javascript"><!--
function image_remove(field, preview) {
	document.getElementById(field).value = '';
	$('#' + preview).replaceWith('<img src="<?php echo $no_image; ?>" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />');
				};
//--></script>
Also remember to add this to your controller file:

Code: Select all

$this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);