0

In my Woocommerce site, I'm creating a lot of downloadable products. The download is the full-size image. I have to set a parameter to the download URL. The code to set the parameter is functioning properly.

What remains is that this code only has to run if the image (media) is a product image. I don't want to set the parameter when it is an image added to a blog post or a page.

I've searched for something like if_is_product_image() or something like that but did not succeed. What can I do?

EDIT: little flowchart to (hopefully) make it more clear

enter image description here

A3O
  • 513
  • 12
  • 29
  • @LoicTheAztec, thanks for your edit. As a value your knowledge and solutions highly.... do you know a solution? – A3O Feb 04 '19 at 13:58
  • Look to [Woocommerce conditional Tags](https://docs.woocommerce.com/document/conditional-tags/) like for example to target single product pages `if( is_product() ) { // Do something }` – LoicTheAztec Feb 04 '19 at 14:07
  • @LoicTheAztec, thanks but that's for handling things on the front end if I'm correct (i.e. single product pages). I'm looking for a solution (again) on product creation. `if_creating_product_and_before_publish() { run function to add parameter to download_file_url from my functions.php on media upload } else { return };` – A3O Feb 04 '19 at 14:23
  • @LoicTheAztec it is an extension to your solution on https://stackoverflow.com/questions/52954367/add-programmatically-a-downloadable-file-to-woocommerce-products What I have now works but also adds the parameter to all media uploads and i need it only on the product image – A3O Feb 04 '19 at 14:30

0 Answers0