Lightbox IFrame

This is a theme component that adds the ability to open iFrames in lightboxes.

Samples

This component adds an “expand” button on top of the iframes you enable it on.

Clicking the button will open the iframe in fullscreen in a lightbox.

Clicking either the dark area around the iframe or the x at the top right corner closes the lightbox. The same way it works for default image lightboxes.

Settings

There’s only one setting. You add the domains that you want to have this functionality on there.

:warning: Whatever domains you specify here also need to be whitelisted in the allowed_iframes site setting to show up in posts in the first place.

Usage examples:

Here’s a couple of examples besides the CodePen iframe above

Google forms iframe:

Embedding the entire weather.gov website:

Credit:

This component uses Noël Bossart’s fantastic Featherlight library (MIT license - 3kb gzip)

31 Mi Piace

I suppose these iframes still also need to be activated in the allowed iframes site setting?

5 Mi Piace

Correct, this component will not mess with any whitelisting settings at all.

In order for any iframe to show up in the cooked content of a post - expandable or not - it has to be on the list of allowed_iframes setting like you pointed out.

I’ll add a note about this to the topic.

5 Mi Piace

@Johani is this component still functional? If so, any thoughts on why I am not getting the pop-out diagonal-arrows in the upper-right, but rather a blank/dead box?

Here is what I’ve tried:

  • Updated themes/components.
  • Made sure src links were white-listed in the component and the Discourse settings.
  • Tried a few different links, including Google Maps.
  • Tried several scenarios with the Media Overlay on/off + Lightbox alone on/off.

Below are some screenshots.

Thx!
-Patrick





image
image
image
image

Dear @Johani,

thank you very much for conceiving and maintaining this theme component.

After installing it on https://community.hiveeyes.org/ the other day, some users recently started to complain that the overall appearance of the head of the page looked different for them. They finally found out the reason was that they blocked cloudflare altogether, so all requests to https://cdnjs.cloudflare.com/ajax/libs/featherlight/1.7.13/featherlight.min.js would fail.

So, we are humbly asking if there would be a way for you to provide this component in a self-contained variant?

With kind regards,
Andreas.

3 Mi Piace

Why is it desktop-only?

I had a bug this theme component, post contents weren’t showing.

Could I trigger open iframe in a any link simply?
User just see iframe only when click at link

1 Mi Piace

Welp… this one fell through the cracks. It’s been a while since it got any attention, and a lot has changed in Discourse.

Better late than never… :upside_down_face:

I just pushed an update that should fix all the problems.

It will be after you update.

The component is now self-contained with no external requests.

After you update, it will work on mobile too.

Should be fixed after you update

This is out of the scope of this component. You need a different component to handle that.

Apologies for the delay, and thanks for the feedback :+1:

7 Mi Piace

Grazie mille!

Non c’è bisogno di scusarsi, è bello vedere che sei riuscito a dedicargli un po’ di attenzione, tra tutte le altre cose che succedono. Lo apprezziamo molto.

1 Mi Piace

Esiste già un componente in grado di aprire un lightbox iframe in un collegamento in quel modo?

Non sono a conoscenza di componenti esistenti che facciano ciò, quindi dovresti crearne uno o commissionare questo lavoro nella categoria Marketplace.

Questo componente del tema controlla iFrame in un post e confronta il loro attributo src con un elenco di origini idonee fornito dall’amministratore nelle impostazioni del componente. Se il dominio di origine corrisponde, aggiunge il pulsante lightbox. La visualizzazione della lightbox è gestita da featherlight.js. Featherlight ascolta i clic sugli elementi con l’attributo data-featherlight. Se uno di questi viene cliccato, apre la lightbox con il contenuto di quell’iFrame.

Puoi fare lo stesso con i tag <a> in un componente diverso con un po’ di lavoro. Se l’href del link corrisponde a un dominio elencato nelle impostazioni del componente, visualizzalo in una lightbox in un iframe. Altrimenti, lascialo come un normale link. Non vuoi che tutti i link si aprano in una lightbox iframe.

La maggior parte del lavoro richiesto è già gestito da questo componente, quindi puoi semplicemente fare un hard-fork e iniziare da lì. Non ci sono piani per aggiungere questa funzionalità a questo componente perché è destinato solo a gestire i tag iFrame nei post.

3 Mi Piace

Ecco un metodo per includere un Lightbox iFrame all’interno di un elemento di testo inline cliccabile…

Il Discourse Footnotes Plugin accetta sia HTML che Markdown all’interno delle note a piè di pagina popup.

Quindi, ad esempio, questo codice…

… genera questa nota a piè di pagina popup cliccabile contenente un mini iFrame con il pulsante Expand content nell’angolo in alto a destra…

Per far funzionare questo, ho (nelle impostazioni del sito) abilitato sia enable markdown footnotes che display footnotes inline

Poi ho aggiunto il nome di dominio di quel sito (microchic.com) all’elenco allowed iframes nelle impostazioni del sito…

… e anche nell’elenco dei iframe origin domains nelle impostazioni dell’iFrame Lightbox Plugin…

Puoi provarlo dal vivo qui…

Ciao, mi stavo chiedendo come formattare i post. Ottengo una casella vuota usando

iframe src=" url" circondato da < > Questo anche quando si utilizza codepen.io che è nella whitelist principale del sito per gli iframe.

Questo componente funziona ancora? In passato funzionava per me ma per qualche motivo ha smesso di funzionare.
Sembra che l’ultimo aggiornamento sia stato 3 anni fa: hnb-ku/discourse-iframe-lightboxes (github.com) Quindi è ragionevole presumere che qualcosa si sia rotto?

1 Mi Piace

Funzionava a maggio, come ho usato qui.

1 Mi Piace

Funziona dalla mia parte con l’ultima versione di Discourse.

Ci sono errori nella console del browser?

2 Mi Piace

Non riesco a farlo funzionare, ho seguito la guida alla lettera e ho aggiunto il dominio sia al componente del tema che all’impostazione del sito. Ecco cosa ottengo:

Nessun errore registrato nella console per sviluppatori di JavaScript.

L’impostazione del sito allowed iframes ha il dominio di primo livello:

https://example.biz/

Le impostazioni del componente del tema lo hanno senza https, come dagli esempi esistenti:

example.biz

Qualche idea su come eseguire il debug?

1 Mi Piace

nessun errore nella console.
Lo sto usando con le anteprime PDF: Inline PDF Previews - #116 by Alon1
Mi aspetto di ottenere le frecce di espansione sopra il PDF

Ma semplicemente non compaiono

Puoi provare questo fork invece?

URL: https://github.com/Arkshine/discourse-iframe-lightboxes
Branch: improve-compatibility

Se prima funzionava, sei stato fortunato!

Entrambi i TC utilizzano la stessa API per decorare un post, quindi l’ordine in cui li installi sarebbe necessario. Inoltre, la sorgente dell’iframe viene impostata dinamicamente una volta scaricato il PDF e potrebbe non essere immediatamente disponibile in questo TC IFrame Lighboxes.

Le modifiche che ho apportato sono fondamentalmente:

  • Cerca gli elementi iframe nel prossimo ciclo di esecuzione, in modo che l’iframe sia garantito essere disponibile
  • Attendi che l’iframe venga caricato in modo da poter recuperare l’URL della sorgente

Fammi sapere se funziona meglio. :+1:

4 Mi Piace