Jump to content

New module for resizing product images


Recommended Posts

Hello,

I have a php script that resizes imagenes and I would like to convert this script into a module to be able to install it in prestashop.

The idea would be to execute this code every time an image is added to a product.

I can code php but I have never created a prestashop module.

Can anybody provide some advise on how I could create this module ?

Thank you.

Link to comment
Share on other sites

2 hours ago, lince said:

Hello,

I have a php script that resizes imagenes and I would like to convert this script into a module to be able to install it in prestashop.

The idea would be to execute this code every time an image is added to a product.

I can code php but I have never created a prestashop module.

Can anybody provide some advise on how I could create this module ?

Thank you.

 

Which is the different between your script/module and the native resizing function?

Link to comment
Share on other sites

1 hour ago, Rolige said:

I have checked the docs but there is only information on how to install and configure.

After that, how can I attach my code to prestashop so it is executed every time an image is uploaded ?

38 minutes ago, joseantgv said:

 

Which is the different between your script/module and the native resizing function?

Native function adds white borders, mine does not.

Link to comment
Share on other sites

On 9/12/2018 at 5:59 PM, Rolige said:

You need works with hooks, PS use 2 hooks in this, actionOnImageResizeAfter and actionOnImageCutAfter

 

Thank you for the information.

I have looked for hooks in the database and ps1.6 only has this hook defined in the database:

actionObjectImageAddAfter

So I checked the classes to see which one is using this hook but none of them is calling it.

In ps 1.7 I was not able to find a single hook with the string "image" in the name.

Also, the issue is that I need to resize the picture before PS does because if I do it after, I would get the image already resized with white borders instead of the original image.

So I was thinking that maybe the only option would be to verride the function resize from the class ImageManager in order to place my functions instead.

Do you think this would be the correct way to do it ?

Thanks.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...