Reputation: 23
I have the following code and the image popup shows nothing. What am I doing wrong?
$('span.confluence-embedded-file-wrapper').magnificPopup({type: 'image'});
And the HTML code:
<span class="confluence-embedded-file-wrapper conf-macro output-inline" data-hasbody="false" data-macro-name="sp-image">
<img class="confluence-embedded-image" src="/space2021/files/582418577/582418579/1/1563720219000/image1.png">
</span>
Upvotes: 0
Views: 166
Reputation: 23
It came out to doing three things.
<script>
count = document.getElementsByTagName('img').length;
href ='';
n = 0;
while (n < (count + 1)) {
imgsrc = document.getElementsByTagName('img')[n].getAttribute('src');
document.getElementsByTagName('img')[n].setAttribute('href', imgsrc);
n = n + 1;
imgsrc ='';
}
</script>
Instead of before or after the magnific call, I had to add it at the end of page after the body tag. It works now.
Delegation :
Modified the call to
$('span.confluence-embedded-file-wrapper').magnificPopup({delegate: 'img' , type: 'image'});
Is there a way to make it work work without inserting the href attribute? src attribute is already there which is what I am pushing to href.
Upvotes: 1