The magnificent popup gallery fails to make an appearance

Can anyone help me with creating a gallery on my website using magnific popup? I'm having trouble getting the images to display in a popup instead of opening in a new tab. How can I set it up so that the images show up in gallery view and allow cycling through all the images on the webpage's gallery? Also, is there a way to customize the size of the lightbox and thumbnails being displayed?

    <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="author" content="">
        <meta name="viewport" content="width=device-width; initial-scale=1.0">

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
      <!-- Magnific Popup core CSS file -->
      <link rel="stylesheet" href="magnific-popup/magnific-popup.css">

      <!-- Magnific Popup core JS file -->
      <script src="magnific-popup/jquery.magnific-popup.js"></script>

      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
      <link rel="stylesheet" href="css/style.css">

  <style type="text/css">

    .modal-dialog {}
.thumbnail {margin-bottom:6px; height: 280px;}

.carousel-control.left,.carousel-control.right{
  background-image:none;
  margin-top:10%;
  width:5%;
}

#open-popup {padding:20px}
.white-popup {
  position: relative;
  background: #FFF;
  padding: 40px;
  width: auto;
  max-width: 200px;
  margin: 20px auto;
  text-align: center;
}

  </style>

  <script type="text/javascript">

    $(document).ready(function() {
  $('.image-link').magnificPopup({type:'image'});

  $('.test-popup-link').magnificPopup({
  type: 'image'
  // other options
});

});




  </script>
    </head>

    <body>
                <div id="main" role="main">
            <br />
                    <br />
        <br />

<div class="parent-container">
  <a href="path-to-image-1.jpg">Open popup 1</a>
  <a href="path-to-image-2.jpg">Open popup 2</a>
  <a href="path-to-image-3.jpg">Open popup 3</a>
</div>


                    </body>
</html>

Answer №1

You're having trouble due to the HTML markup!

<a href="path-to-image-1.jpg">Open popup 1</a>
doesn't seem to be working.

<a class="test-popup-link" href="path-to-image-1.jpg">Open popup 2</a>

However, using this code will work.

Take a look at Codepen for more details.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with mouseout gap in Microsoft Edge when using the <select> element

A noticeable gap appears in Microsoft Edge between the <select> menu and its options when expanding the menu, as shown here: https://i.stack.imgur.com/SprJ2.png This particular issue can cause problems with the mouseout event due to inconsistent be ...

Request for "/media/img/image.png" was made using HTTP/1.1 but ended in a 404 error with a response size

Upon loading the page, there seems to be an issue with the image not appearing. The image was uploaded using Django-admin. Below is the section of the HTML template responsible for loading the image: Home.html <img class="card-img-top" src=&q ...

The Art of CSS Arrangement

I'm experiencing an issue on my website PSR Is there a way to ensure that the Footer always appears below the content div automatically? Both the Content and the Footer have relative positioning. Additionally, how can I make the Footer the same siz ...

Issues with CSS positioning

I'm facing an issue with the jQuery drop-down bar slipping behind images on a specific page that uses jQuery innerfade. You can see the problem here: <?php include('perch/runtime.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

Tips for maintaining a consistent paragraph height even in the absence of text

I am facing an issue with two skinny boxes in the code below. Each box contains a paragraph as a child element. The first paragraph has text while the second one does not. The problem arises when the text is removed, causing the paragraph to lose its heigh ...

Make a gap between two buttons on my banner

How can I create a space of 0.5 cm between 2 buttons in my banner? I have been stuck on this for a while now. Do I need to modify my HTML blocks? https://i.sstatic.net/74yBh.png Below is the CSS code I am currently using: .myButtonRegister{ float: left ...

What benefits does a dynamic website like this offer compared to one that is purely AJAX-based?

There are two main categories of dynamic websites that I define: The first type utilizes languages like PHP to concatenate an HTML page and send it back to clients. On the other hand, the second type uses an HTML template where all interfaces provide JSO ...

PHP echo statement does not contain Div, yet Div renders properly when placed outside the echo statement

I am facing an issue where my photos are not displaying as expected. The photos div shows up perfectly fine when placed outside the echo statement, but for some reason, it does not render when echoed. The structure of my divs is organized like this: userp ...

Preserve appearance when saving .html document (React)

Below is a simplified version of my React component: export class SomePage extends Component { downloadAsHTML() { const element = document.createElement("a"); const file = new Blob([document.getElementById('second-child-div').outerHTM ...

Is it possible to fix the rightmost column in a scrollable HTML/CSS table with Angular when using overflow-x?

Is there a way to lock the right-most column in an HTML CSS Angular table that is scrollable using overflow-x? I have attempted using the sticky property and also creating two tables side by side, but neither method has successfully achieved the desired ...

Instructions for implementing this script in HTML and JavaScript: utilize the clone() function

I came across this code snippet here function displaytickets(){ var $panel = $('<div/>').addClass('col-xs-3 panel panel-default') $panel.append($('<div><h3 class="panel-title">Title</h3></div>&a ...

Can you please provide the CSS code that would style this table in a similar manner?

I am interested in utilizing the design of this table, but how can I update it to meet CSS standards and HTML5 equivalents? <html> <head></head> <body> <table border="1" bordercolor="#000000" style="background-color:#ffffff" w ...

Ways to prevent decreasing the value below zero in ReactJS?

I have created two buttons, one for increasing and another for decreasing a counter value. However, when I click on the minus button, it should not display negative values. But in my case, when I click on the minus button (initially at zero), it shows -1, ...

Guide to declaring variables using jQuery

Currently tackling a school project, I stumbled upon some online example solutions and managed to decipher most of the code. However, there is one line that has me puzzled. var $newTweet = $('<div class=tweet></div>'); My assumption ...

The multi-level navigation bar is not displaying properly

I am currently facing an issue with my Mega menu. It displays two levels of menus perfectly fine, but I need to add a third level as shown in the image below. However, when I try to include the third level, it disrupts the design and causes the Grand Child ...

Identify regions with clickable functionality within an <img> element in an Ionic application

I have a static image with various buttons like Main, F1, F2, etc. within it that need to be made clickable in order to call an API. I am looking for suggestions on how to achieve this scenario. Any assistance would be greatly appreciated.https://i.sstat ...

Looking for a responsive solution to automatically scroll a horizontal grid to a specific position when the page loads

Eight years ago, a user asked a similar question on this platform: DIV Horizontal scroll, how to onload to ID The answer provided was: document.getElementById('foo').scrollLeft = 500;​ However, I am currently working on a Bootstrap 4 website ...

How can recursive data be displayed in a template?

I am working with a model in Django that has a ForeignKey pointing to itself, and I need to display all the data from the database using lists and sublists: Below is my model definition: class Place(models.Model) name = models.CharField(max_length=1 ...

How do I get rid of the form border and shadow on my WordPress login page?

Currently revamping the appearance of the Wordpress login page and most aspects are coming together smoothly. I opted to utilize a separate css file for this project, which has been effective overall. However, one issue persists. I've encountered diff ...

Trouble Aligning HTML in OUTLOOK's Center Position

Today, I've invested hours into solving an issue with my HTML email layout. It seems to display perfectly on most email clients except Outlook – the centering of the layout in the preview just won't cooperate. I've attempted using the < ...