Nishith Nesdiya Posted July 11, 2016 Share Posted July 11, 2016 Hi.all my friendsi am upload the image file using helper form like as array( 'type' => 'file', 'desc' => sprintf($this->l('icon. Maximum image size: %s.'), ini_get('upload_max_filesize')), 'label' => $this->l('icon'), 'display_image' => true, 'name' => 'ICON_FILEDS', 'thumb' => '../modules/'.$this->name.'/views/img/'.Configuration::get('ICON_FILEDS'), ), its working the and display image correct but my problem is how to delete that image when one time is uploadedsee the image.thanks Link to comment Share on other sites More sharing options...
rocky Posted July 13, 2016 Share Posted July 13, 2016 I think you'll need to override the TPL file and add a Delete button yourself. At least that's what I did for my Image/Video Gallery module. For example, I have the following code in modules/gallerync/views/templates/admin/gallerync_galleries/helpers/form/form.tpl (change gallerync to your module name and gallerync_galleries to the controller's table name): {block name="input"} {if $input.type == 'file' && $input.name == 'cover'} {if isset($input.display_image) && $input.display_image} {if isset($fields_value.cover) && $fields_value.cover} <div id="image"> {$fields_value.cover} <p>{l s='File size' mod='gallerync'} {$fields_value.cover_size|intval}kb</p> <a class="btn btn-default" href="{$current|escape:'htmlall':'UTF-8'}&{$identifier|escape:'htmlall':'UTF-8'}={$form_id|intval}&token={$token|escape:'htmlall':'UTF-8'}&deleteCover=1" style="margin-bottom:12px"> <i class="icon-trash"></i> {l s='Delete' mod='gallerync'} </a> </div> {/if} {/if} {/block} This will add the file size and a "Delete" button. I put the following code in the renderForm() function of modules/gallerync/controllers/admin/AdminGalleryNCGalleriesController.php to create the $fields_value.cover and $fields_value.cover_size Smarty variables: $this->fields_value = array( 'cover' => $cover ? $cover : false, 'cover_size' => $cover ? filesize(_PS_MODULE_DIR_.'gallerync/views/img/covers/'.$obj->id.'.'.$obj->cover) / 1000 : false, ); I hope this helps. 1 Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted July 18, 2016 Author Share Posted July 18, 2016 thanks overriding helper form wroking thanks you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now