0

I am adding an image gallery via wp media uploader. In the frontend, I am trying to show these images in Thickbox pop-up. However, it shows the images in pop-up but when I navigate [next and prev images] it suddenly works and an error is seen in the console.

This is the error: http://example.com/wp-content/uploads/2019/03/IMG_0139.jpg&width=753&height=470?random=1555568706302 404 (Not Found). If I paste this url, 404 page is seen.

All in all, the navigation buttons are not working properly. If I add 2 images in gallery, the next button box works but prev button throws error. If I use more than 2 images, the next disappears after second images and prev button fails as well.

This is my code for front-end where images are displayed:

<?php
foreach ($ids as $key => $value):
    $image_medium = wp_get_attachment_image_src($value, 'medium');
    $image_full = wp_get_attachment_image_src($value, 'full');
    $attachment_title = get_the_title($value);
?>
    <li>
        <a rel="gallery" href="<?php echo esc_url($image_full[0]); ?>">
        <img class="guide-gallery-image" alt="<?php echo esc_attr($attachment_title); ?>" src="<?php echo esc_url($image_medium[0]); ?>" />
        </a>
    </li> 
<?php
endforeach; ?> 

This is how I have added thickbox() resources (css and js) in my footer:

<?php
add_thickbox();
get_footer();
?>
  • 1
    That URL is obviously invalid (query string starts with the ? simbol). But your code works fine for me, except there should be a class="thickbox" in the <a> tag... – Sally CJ Apr 18 at 6:59
  • @SallyCJ That url is auto generated from the thickbox(). Is the navigation working? – saurav.rox Apr 18 at 7:43
  • 1
    Yes, it is working properly. Why didn't you add the thickbox to the link (a) class? Do you have a custom script which setups Thickbox on the links? – Sally CJ Apr 18 at 13:24
  • 1
    Ok, but you haven't answered my other question - is there a script which automatically setups Thickbox on the links? Because to me, it seems there is. Try disabling all plugins and/or try a default theme. – Sally CJ Apr 20 at 0:06
  • 1
    My mistake. There was a JS error in my code which triggered this error. Now both are fixed. Thank you. – saurav.rox Apr 22 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.