Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2016-03-15 05:51:35

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Add floating button to Magnific images

First of all, I am new to PHP plugins. I was wondering if it would be possible to a a floating button on top of the large Magnific images? I would like it to link to another webpage. Thanks in advance!

Monte

Offline

#2 2016-03-15 06:32:28

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Add floating button to Magnific images

I don't think it's going to be a phplugins sort of enhancement unless it's to inject additional javascript into a gallery page. You'll likely need to alter the Magnific javascript, if it's even possible to do what you want. Here's the documentation page for Magnific:
http://dimsemenov.com/plugins/magnific- … ation.html

Depending on exactly what you're trying to do, there may be another way. For example, if you simply want a gallery of images that all link to different pages, that's easy enough to do with Autoindex and the Autoindex Enabler.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2016-03-15 06:37:22

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Hi Rod. All I really want to do is have a link for each large image to go to another webpage. I tried the HTML trick of adding a href in the caption and it shows up, but when I go to click on it, the top bar and bottom bar go away. The Autoindex idea won't work because the main reason for the gallery is to view the images large. Thanks much!

Monte

Offline

#4 2016-03-15 07:59:21

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Add floating button to Magnific images

I'm guessing the html in the caption is messing with the script. Are you using double quotes or single quotes in the link html?
If single, try double. If double, try single.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#5 2016-03-15 08:04:26

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

I am using single quotes and it seems to be working fine. If I hover over the link, the correct path shows. The problem is that the behavior for when you click on on a large image is to cycle between turning the top and bottom bars on and off. You can never click on the link! Thanks for your help Rod.

Monte

Offline

#6 2016-03-15 15:07:48

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add floating button to Magnific images

Hi Monte,

Does the button have a unique link for each image, or do all images have the same button (w/ same destination)?

You would want to look at my code for launching Magnific. There's already lots of examples in there how to add a button to the interface, as that's exactly what my code is doing. You'll find that in the footer area of the page's source code, not in the .js file.

Or if you're working in the plugin source, rather than the exported gallery, then you'd find it in /lib/js/magnific.cfg.js.

The section beginning here is the physical markup for the buttons:

                image: {
                    markup: '<div class="mfp-figure">'+

What occurs when clicking those buttons is defined in the "delegate" functions above that. You'll see that each button has it's own delegate function matched by class.

So this button:

                                    '<li class="mfp-permalink"><a><i class="fa fa-fw fa-link"></i></a></li>'+

Is governed by this delegate function:

                    .delegate(".mfp-permalink a","click", function(e){
                        e.preventDefault();
                        window.location.href= albumURL + currentImage + "-single.php?mobile=true";
                    })

If you want to add a button, then you'll need to setup a similar pair of new items, then provide styling for the button in your custom CSS.

Take note, adding a button here is NOT a job for PHPlugins. You will need to get your hands dirty and make additions to the source, either in the plugin itself or in an exported gallery template.

I hope that's helpful.

Cheers,
Matt


Matt

The Turning Gate, http://theturninggate.net

Offline

#7 2016-03-15 22:04:58

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Thanks Matt. I will dig in and see what I can do. I sure appreciate the help!


Monte

Offline

#8 2016-03-16 07:27:25

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Hi Matt. I have been playing around with this today. If possible I would want the button to be unique per image. Would it be possible to put that info in the image metadata and use it as a variable in the Magnific javascsript? Thanks Matt.

Monte

Offline

#9 2016-03-16 17:12:38

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add floating button to Magnific images

trummonte wrote:

Hi Matt. I have been playing around with this today. If possible I would want the button to be unique per image. Would it be possible to put that info in the image metadata and use it as a variable in the Magnific javascsript? Thanks Matt.

Monte

Well, there are two ways to go about it then.

The easiest way, if you have control over these button URLs, is to make those URLs uniform, except for the image file name. This is basically what we do with our single-image HTML pages. So you might have URLs like:

domain.com/always-the-same-path/image-file-name.html

or:

domain.com/always-the-same-path/uniform-prefix_image-file-name.html

In which case, you can get the file name using Javascript, then build your delegate around it. In the code we've already written, the image id is "currentImage", which is the file name without ".jpg". Look at what we're doing with the permalinks' delegate function, and you can see how we concatenate that id in a URL for the single-image page. Do something similar for your buttons.

The difficult way -- if you don't have the luxury of uniformly constructed URLs, or if the URLs cannot be formed using the image id -- is to edit the image loop in the gallery template or plugin, and that's going to get dicy. You'll want to insert an HTML5 "data-" attribute, which you can later pull using Javascript.

The exported gallery template will be easier for you to parse. The plugin code ... well, I wrote it and even I don't like to work on it. It's as clean as I can make it, but the nature of Lightroom plugins is such that the code is a nightmare by necessity.

Hopefully you can use the former approach, and leverage the variables we've already built into the Magnific CFG script that you're editing.


Matt

The Turning Gate, http://theturninggate.net

Offline

#10 2016-03-17 00:59:06

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Thanks Matt. I figured out I could do it the easy way and use the file name. It works just great. Here is a link to a gallery (work in progress) that I have it setup with:

https://www.portfolios.montetrumbull.com/galleries/

Clicking on the shopping cart button will take you to the same image at ArtStoreFronts. I am going to be trying out their service but still wanted my favorite images in a nice gallery like yours! I will also be using TTG for my blog and client and family albums.

Thanks so much for your help.

Monte

Offline

#11 2016-03-17 15:57:53

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add floating button to Magnific images

Glad you're able to do it the easy way.

Strangely, though, I'm not able to access your gallery to check things out. If displayed errors are to be believed, the page seems to get stuck in a redirect loop. You might need to troubleshoot your Javascript, else it might be something odd with .htaccess or PHP redirects. Either way, highly peculiar.


Matt

The Turning Gate, http://theturninggate.net

Offline

#12 2016-03-18 01:10:31

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Add floating button to Magnific images

Works fine for me. I like the 'hack' you did to use ArtStoreFronts. This works well!

BTW, when I do hacks like this, I am overzealous and keep a copy of the changes as a separate copy outside of the TTG installation. This way I still can get my changes back even if I overwrote my template file due to a version update... yep, it happened ;-)   And then there is always yet another backup.


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#13 2016-03-18 01:17:24

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Thanks Matt & dl. Matt, I am pretty sure the problems you were having were due to me installing a new security certificate and some changes I made to .htaccess (bad timing!). Things are getting cleaned up this morning.

dl, I made sure to save a copy of the file!

Monte

Offline

#14 2016-03-18 01:34:13

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Hey Rod. I am still waiting to hear back from Dreamhost to get my certificates in order. I use Cloudflare which adds another layer of complexity! You can get to the unsecure site at: http://www.portfolios.montetrumbull.com/galleries/ for now. Thanks!

Monte

Offline

#15 2016-03-18 01:36:51

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Add floating button to Magnific images

after re-reading your earlier post that things were getting cleaned up, I deleted what I'd posted, figuring you already knew.

But your new button works great!


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#16 2016-03-18 01:38:19

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Thanks Rod!

Offline

#17 2016-03-18 01:43:08

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Add floating button to Magnific images

What you've done is pretty cool. I'm guessing others will be asking you how you did it wink

Looks like you ended up using the image title for the url to ArtStoreFronts?


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#18 2016-03-18 14:20:59

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Add floating button to Magnific images

I'm still getting issues with the cloudflare security nonsense. Visiting the unsecure address works better for me.

This is what I've got:

There are issues with the site's certificate chain (net::ERR_CERT_COMMON_NAME_INVALID).

And this:

This server could not prove that it is www.portfolios.montetrumbull.com; its security certificate is from ssl277278.cloudflaressl.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

Fun stuff, I know. Hopefully that will help you with your host.

Getting a look at the site, I always love to see your incredible images. Tremendous stuff!

Digging into your Javascript, you might update your delegate function to use "window.open", rather than "window.location". This will allow you to open the link in a new browser tab, keeping the gallery open.

.delegate (".mfp-artstorefronts a","click", function(e) {
    e.preventDefault();
    window.open("http://montetrumbull.artstorefronts.com/galleries/art_print_products/" + artstorefrontsTitle);
})

Matt

The Turning Gate, http://theturninggate.net

Offline

#19 2016-03-19 04:11:56

trummonte
Member
From: Buena Vista, Colorado
Registered: 2012-11-11
Posts: 178
Website

Re: Add floating button to Magnific images

Thanks Matt. Good suggestion. All is finally well with my security certificates. It really screwed things up there for a while!

Monte

Offline

Board footer

Powered by FluxBB