[Skip to main content](#vessel-content)

#   Hhow to customize Product Image upload code?

##

- **[dixit](/forum/user/61778-dixit "View dixit's Profile")**
- [![dixit's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/61778-dixit "View dixit's Profile") Topic Author
- [ Offline](/forum/user/61778-dixit)

Less More

- Posts: 3
- Thank you received: 0
-
-

5 years 3 months ago [\#334459](#334459) by [dixit](/forum/user/61778-dixit "View dixit's Profile")  *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334459 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")* was created by *[dixit](/forum/user/61778-dixit "View dixit's Profile")*

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.27
-- PHP version -- : 8.0.7
-- Browser(s) name and version -- : chrome
-- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?

when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

5 years 3 months ago [\#334463](#334463) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334463 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")*

Hi,

You could just change the "upload folder" of the HikaShop configuration to where you want the images to be uploaded instead of the default folder.

Now, to answer your question, supposing that you want to override this setting with a dynamic path, I would recommend you to do it by developing a system plugin. In it, you could implement the onAfterRoute event of Joomla. In there, you would include_once the main helper.php file of HikaShop ( administrator/components/com_hikashop/helpers/helper.php) and then force the upload path with such code: Code:

$config = hikashop_config(); $config-&gt;set('uploadfolder', 'xxx');

where xxx is the path you want instead of the one set in the config.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dixit](/forum/user/61778-dixit "View dixit's Profile")**
- [![dixit's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/61778-dixit "View dixit's Profile") Topic Author
- [ Offline](/forum/user/61778-dixit)

Less More

- Posts: 3
- Thank you received: 0
-
-

5 years 3 months ago -  5 years 3 months ago [\#334480](#334480) by [dixit](/forum/user/61778-dixit "View dixit's Profile")  Replied by *[dixit](/forum/user/61778-dixit "View dixit's Profile")* on topic *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334480 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")*

Code:

$config = hikashop_config(); $config-&gt;set('uploadfolder', 'xxx');

where xxx is the path you want instead of the one set in the config.[/quote]

Ok so with this code I can change default image upload path. What I want is when one image upload from product image upload admin I want create three different images with different resolution like(large,medium,small) and it to their respective paths like large image store in pics/large folder and medium image is stored in pics/medium folder like this. In short I want to customize the product admin image upload code. Is it possible?

Last edit: 5 years 3 months ago by [dixit](/forum/user/61778-dixit "View dixit's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

5 years 3 months ago [\#334482](#334482) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334482 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")*

Hi,

In that case, you could create a plugin of the group "hikashop" and implement the event onAfterFileCreate(&amp;$file)
This method of your plugin will be called each time a new file is created (be it an image or a file). Then, in $file you'll have the file_type that you can check so that you process only images. And the file_path attribute will contain the relative path of the file in the upload folder. From that, you can load the image, resize it and save the result where you want.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[dixit](/forum/user/61778-dixit "View dixit's Profile")**
- [![dixit's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/61778-dixit "View dixit's Profile") Topic Author
- [ Offline](/forum/user/61778-dixit)

Less More

- Posts: 3
- Thank you received: 0
-
-

5 years 3 months ago [\#334521](#334521) by [dixit](/forum/user/61778-dixit "View dixit's Profile")  Replied by *[dixit](/forum/user/61778-dixit "View dixit's Profile")* on topic *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334521 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")*

> nicolas wrote: Hi,
>
> In that case, you could create a plugin of the group "hikashop" and implement the event onAfterFileCreate(&amp;$file)
> This method of your plugin will be called each time a new file is created (be it an image or a file). Then, in $file you'll have the file\_type that you can check so that you process only images. And the file\_path attribute will contain the relative path of the file in the upload folder. From that, you can load the image, resize it and save the result where you want.

Ok, this is working fine. but if I will delete the uploaded image from the product admin then how can I delete the other images which were created from that image by onAfterFileCreate(&amp;$file) method of the plugin.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

5 years 3 months ago [\#334524](#334524) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Hhow to customize Product Image upload code?](/forum/4-how-to/902970-hhow-to-customize-product-image-upload-code#334524 "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.27 -- PHP version -- : 8.0.7 -- Browser(s) name and version -- : chrome -- Error-message(debug-mod must be tuned on) -- : How to add manual code for product image upload?  when the image is uploaded from hikahop product admin I want to upload this image at a custom path instead of the default hikashop image upload path.")*

Hi,

We do have the event onAfterFileDelete for that.
However, looking at the file there, I can see a problem with how we've added it previously.
The first parameter is an array of ids, but the entries are already removed from the database by that point.
So that won't help.
To fix that, you need to change the line: Code:

$app-&gt;triggerEvent('onAfterFileDelete', array( &amp;$pkeys, &amp;$type ));

to: Code:

$app-&gt;triggerEvent('onAfterFileDelete', array( &amp;$oldEntries ));

in the file administrator/components/com_hikashop/classes/file.php
That way, in $oldEntries you'll get an array of the files that were just deleted (we'll remove the $type variable since each element of the array has a file_type with its type).
We'll include that modification in the next version of HikaShop and we'll also add a onBeforeFileDelete in that same deleteFiles function.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjk3MC1oaG93LXRvLWN1c3RvbWl6ZS1wcm9kdWN0LWltYWdlLXVwbG9hZC1jb2RlP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.282 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
