Whenever I click on a picture, my goal is to immediately download it. The image is SVG, but there's an URL for a PNG version. It has been confirmed that the content disposition is set to attachment, and when the URL is directly copied, a download process initiates.
Bootstrap 4 is the framework in use.
The following function is being employed:
function downloadPNGImage(linkElement) {
var myDiv = document.getElementById('download-area');
var myImage = myDiv.children[0];
let downloadLink = myImage.src + "&format=png";
linkElement.setAttribute('download', downloadLink);
linkElement.href = downloadLink;
}
The image itself is shown below:
<div class="col-lg-5 order-first order-md-last img-fluid" id="download-area">
<img src="https://bananomonkeys.herokuapp.com/image?address=ban_1ttyqinz739g88tteqzyg3hwahg9oxbks8amsywqmim7j4afih7n9d1ssqjf&bg=t"
class="loaded" id="generated-monKey" alt="" href="#" onclick="downloadPNGImage(this)" download>
</div>
Including "&format=png" should convert this URL from inline SVG to an attached PNG for downloading purposes. However, despite these efforts, the download feature does not seem to be functioning correctly.