1

I dont know anything about Javascript. I'm using Ignite theme in Wordpress. I tried to add a lightbox gallery in my site: http://dimsemenov.com/plugins/magnific-popup/ > the "Zoom-gallery" example

So I put the html code in the post, the CSS in style.css, but I dont know where I have to put the javascript. I tried to past it (between script tags) inside the content-page.php, content.php, header.php, or footer.php but it didn't work.

HTML

<div class="zoom-gallery">
    <a href="http://farm4.staticflickr.com/3763/9204547649_0472680945_o.jpg" data-source="http://500px.com/photo/32736307" title="Into The Blue" style="width:193px;height:125px;">
        <img src="http://farm4.staticflickr.com/3763/9204547649_7de96ee188_t.jpg" width="193" height="125">
    </a>
    <a href="http://farm3.staticflickr.com/2856/9207329420_7f2a668b06_o.jpg" data-source="http://500px.com/photo/32554131" title="Light Sabre" style="width:82px;height:125px;">
        <img src="http://farm3.staticflickr.com/2856/9207329420_e485948b01_t.jpg" width="82px" height="125">
    </a>
</div>

CSS

.image-source-link {
    color: #98C3D1;
}

.mfp-with-zoom .mfp-container,
.mfp-with-zoom.mfp-bg {
    opacity: 0;
    -webkit-backface-visibility: hidden;
    -webkit-transition: all 0.3s ease-out; 
    -moz-transition: all 0.3s ease-out; 
    -o-transition: all 0.3s ease-out; 
    transition: all 0.3s ease-out;
}

.mfp-with-zoom.mfp-ready .mfp-container {
        opacity: 1;
}
.mfp-with-zoom.mfp-ready.mfp-bg {
        opacity: 0.8;
}

.mfp-with-zoom.mfp-removing .mfp-container, 
.mfp-with-zoom.mfp-removing.mfp-bg {
    opacity: 0;
}

JAVASCRIPT

$(document).ready(function() {
    $('.zoom-gallery').magnificPopup({
        delegate: 'a',
        type: 'image',
        closeOnContentClick: false,
        closeBtnInside: false,
        mainClass: 'mfp-with-zoom mfp-img-mobile',
        image: {
            verticalFit: true,
            titleSrc: function(item) {
                return item.el.attr('title') + ' &middot; <a class="image-source-link" href="'+item.el.attr('data-source')+'" target="_blank">image source</a>';
            }
        },
        gallery: {
            enabled: true
        },
        zoom: {
            enabled: true,
            duration: 300, // don't foget to change the duration also in CSS
            opener: function(element) {
                return element.find('img');
            }
        }

    });
});

1 Answer 1

2

Find actual theme folder . There should be folder called "js" if not crate it put this script into some js file in that "js" folder and include it in file called index.php in same directory.

Sign up to request clarification or add additional context in comments.

14 Comments

Thats ok I just installed Notpad++ and now its working. So do I have to add the script between <script> tags or alone in my test.js file? Also I dont get this: "and include it in file called index.php in same directory"
No you needn't . just put ready function into that js file save it and include into index.php using script tag.
It doesn't work. I probably did something wrong. I created a js file inside js folder, put the javascript, saved it. Then found the index.php which is in "Ignite" folder and put the script between script tags at the end of the file and saved it
@edou777 make sure that js file was included successful. In chrome open dev console and look for 404 errors.Or look page source .
Ok thats what I didn t get in your first answer. What do you mean by "include" js file in index.php?? What I did was just past the javascript at the end of the index.php file.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.