• Hi,

    I have an issue with the [gallery] shortcode that I can’t seem to find a solution to. At standard, it opens the images within a new window. I need them to open up (enlarge) within the page, like a modal instead. The images comes from Advanced Custom Fields, and them being dynamic makes it the more troublesome.

    I’m not very good with PHP, and as far as my research showed me I can only do link=”none”. Is there any way to do what I’m searching for? I suppose some PHP is needed, but scouting forums etc. for a solution has yet yeilded me no answer.

    I hope someone can point me in the right direction!

    Merry Christmas and happy holidays,

    Dannie

    • This topic was modified 2 years, 11 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    If you want modal behavior (lightbox like), it’ll require JavaScript or jQuery. PHP is only involved as far as generating the proper HTML structure that the modal code is expecting. The grid generated by the gallery shortcode may or may not be suitable.

    I recommend trying out a few of the lightbox gallery plugins.
    https://www.ads-software.com/plugins/search/lightbox+gallery/

    Thread Starter dannieaj

    (@dannieaj)

    Hey, and thanks for the answer! I have already tried a few of them – problem is I need the content of the gallery to be dynamic, pulled from ACF. It seems to be among the harder things to do, I havn’t yet found a plug-in that could handle it!

    Moderator bcworkz

    (@bcworkz)

    I see. Perhaps you’d be better off with just the lightbox (or similar) jQuery library alone. Not being a WP plugin, you’d be responsible for integrating it into WP via your own custom plugin code. FWIW, WP has “Thickbox” already local and registered, you merely need to enqueue it on gallery pages.

    The gallery page’s dynamically generated HTML would need to be structured in a specific way that’s compatible with the library. Typically a list of anchored images. And you probably need a bit of custom JS to initialize the lightbox for that specific gallery. There are variations of what’s necessary, depending on the specific library you choose.

    If you want to use thickbox, see https://codylindley.com/thickbox/ and https://codex.www.ads-software.com/Javascript_Reference/ThickBox

    If you’d rather use the original Lightbox, it’s here: https://lokeshdhakar.com/projects/lightbox2/

    And of course there are dozen’s of variants available once you venture outside of WP plugin territory.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP Gallery – How do you enlarge img instead of linking?’ is closed to new replies.