1
votes

I work in MODx Evolution and created a template variable which is an image. I want this image to be downloadable by my website visitors. Is that possible, how?

This link gives valuable info... but the issue with my requirement is the MODx template variable and the fact that I do not have a specific path to specify. ... similar Stackoverflow question answered

1
I don't understand completely: Can't you link to the image and then the user downloads it per context-menu or menu-options? Or do you want it to be automatically downloaded by the browser when clicked on the link like most ZIP/PDF files? - Sebastian G. Marinescu
@Sebastian G. Marinescu - Below answer helps me because I had the issue with the template variable path, but your answer helps as well, because I want to know how to do the browser download when clicking on link so that ZIP file appears for download, how to do? Thanks. - user4752928
The keywords you are looking for: content disposition attachment. If you still need help, open up a new question and post the link here. - Sebastian G. Marinescu

1 Answers

0
votes

What is happening is that your TV output type is set to "image" - Modx will output an image tag in that situation and not just the path. You can change the output type to default so that only the path is output, then you can pass that to your download/push scripts. OR leave the TV type as is and write another snippet to retrieve the TV value, which will be the path & filename. Docs here

Something like:

/call snippet
[[!getMyTVvvalue? &id=`[[*id]]`]]

// snippet 
$resource = $modx->getObject('modResource', $id);
return $resource->getTVValue('my_image_tv');

// might be handier to output it to a placeholder
$my_path = $resource->getTVValue('my_image_tv');
$modx->toPlaceholder('my_image_path', $my_path);

// output in your page
[[+my_image_path]]

Though it would be easiest to just change your output type.