Mdkart

Etudiant en médecine à Lille : nouvelle vague Jazz Blues (Melua, Stahl, Gardot, Yanofsky…) et autres musiques, Moto, Photo…

Slide Add Ligthbox

Plugin Add Lightbox pour WordPress

| 217 Commentaires

For English Speakers

Francophones voir plus bas
This plugin for WordPress automatically add the rel= »lightbox[ID_OF_THE_POST] » to images linked in a post. So you will never have to add rel= »lightbox[ID] » when you write a new post.
ID_OF_THE_POST is unique per post so all images per post are grouped in one lightbox set.
All you have to do is make a link to an image.
Works also with the gallery Fonction of WP and in comments
Slide Add Ligthbox

Doesn’t add the the files required for Lightbox (it’s only add the rel lightbox tag)! You have to insert yourself in your theme the required files that you can find here or use a WordPress plugin that will add the script without editing anything.
If you don’t understand how it works, see the comment of James T.

You can also use other Lightbox-like scripts (I personnaly use Slimbox) but sometimes it will need some minor and easy modifications :
Examples :
In the plugin, on the line 17 ( $replacement = ( … ) Replace rel=”lightbox[%LIGHTID%]” by

Inspired by this thread

Download the Plugin Add Lightbox v0.4.1

V0.4.1

  • Optimizing the code

V0.4

  • Now Compatible with the Gallery Fonction of WP
  • Adds also rel tag in the comments

V0.3

  • Correction of a bug that added rel tag on links done on img tags. Thanks to Hank for the description of the bug

V0.2

  • Correction of a small bug described by Kristof Mattei. Thanks to him for the help!

Pour francophones

Ce plugin pour WordPress ajoute automatiquement l’attribut rel= »lightbox[ID_OF_THE_POST] » aux liens faits vers des images dans un billet. Ainsi, il devient inutile d’ajouter manuellement à chaque image dans chaque billet cet attribut.
ID_OF_THE_POST est unique à chaque billet, donc les images d’un même billet sont regroupés dans un même set d’image lightbox créant ainsi une mini galerie.
Tout ce que vous avez à faire est de faire un lien vers une image.
Fonctionne également avec la fonction Galerie de WordPress et dans les commentaires

Ce plugin n’ajoute pas les fichiers nécessaire au fonctionnement de lightbox. Il ajoute uniquement l’attribut rel= »lightbox[ID]« . Vous devez insérez vous même dans votre thème les fichiers nécessaires que vous pouvez trouver or utiliser un plugin WordPress qui ajoutera le script sans mettre les mains dans le cambouis.
Il est également possible d’utiliser d’autres scripts similaires à Lightbox (j’utilise par exemple Slimbox) mais cela demandera parfois de petites modifications très faciles :
Exemples :
Dans le plugin, à la ligne 17 ( $replacement = ( … ) Remplacer rel=”lightbox[%LIGHTID%]” par

Inspiré par cette discussion

Télécharger le plugin Add Lightbox v0.4.1

V0.4.1

  • Optimisation du code

V0.4

  • Maintenant Compatible avec la fonction Galerie de WordPress
  • Ajout des tags rel= »lightbox » dans les commentaires

V0.3

  • Correction d’un bug qui ajoutait le tag rel aux liens faits sur des images. Merci à Hank pour m’avoir reporté le bug

V0.2

  • Correction d’un petit bug décrit par Kristof Mattei. Merci pour son aide!

Auteur : Mdkart

Interne en anesthésie réanimation à Lille, je présente sur ce blog des tranches de ma vie et mes passions : voitures sportives et moto, photo, nouvelle vague Jazz-Blues (Katie Melua, Fredrika Stahl, Melody Gardot, Nikki Yanofsky...) et autres musiques...
Pour toute information, n'hésitez pas à me contacter ou à m'ajouter sur Google+

Catégories : En Vrac | Mots-clés : ,

217 Commentaires

  1. Pingback : Lightbox test plugin

  2. Pingback : WordPress plugins: Lightbox

  3. Pingback : 47drölf » Meine Teststrecke

  4. I cannot get this to add the rel= »lightbox » to the link.
    any known reasons why not?

    • Hi,
      I don’t understand. I’ve tried the syntax you use in your post to insert images, but in my wordpress installation, and it works.
      The plugin is activate in the wordpress plugin administration page?
      It may be also a conflict with an other plugin. Can you try desactivate other plugins and tell me if it works?

    • This is not working on the Phillipwray Racing website, so I have had to manually add the rel=”thumbnail” (instead of lightbox as I am using thumbnail instead of lightbox).

      I have these plugins installed on the website:
      Buy me beer
      cforms
      enforce www preference
      google sitemaps
      iGallery
      One click installer
      random image
      excerpt reloaded
      thumbnail viewer
      wp-slimstat

    • Hi,
      Can you try :

      -First : use this syntax: Only modify URL_OF_THE_PIC with one of yours and tell me if it adds rel=”lightbox[ID_OF_THE_POST] »

      <a href=’URL_OF_THE_PIC’ title=’test’>A test </a>

      – If it doesn’t work, can you test deactivate all other plugin than Add lightbox and telling me if it works. If it works reactivate them one by one to see where the problem came from.

      – If it doesn’t work with all other plugins deactivate, tell me what version of wordpress you use and if you know what version of php you have on your server.

      Thanks

    • Thanks for that..

      It was the iGallery plugin that was causing the problem.
      Thanks again for your help

    • Many thanks to let me know that it is a conflict with iGallery! :)

    • Yeah its a real pleasure to have it working, thanks for your help mate

  5. Pingback : 89 Wordpress Plugins | SEO | SEM | Affiliate Blog by Andy Huang

  6. Pingback : Add Lightbox | ????????

  7. Pingback : Warriors for Christ websites dissected

  8. Brace yourself… I’ve linked to this page (great plugin, BTW! Beat me to it!) from my lightbox page. I’ve been trying to think of a way to check if a link already has a « rel » and if so, skip it. Any ideas?

    • Hi,
      Many thanks for the link!
      I think it’s possible but I haven’t many times to do it at this time.
      Anyway, is it really useful to have this function : it will make the plugin slower and I think that it works even if there are two rel= »lightbox » for a same pic.
      What do you think about this?

  9. Pingback : Chris Brogans blog topics GermWorks answering - WordPress plugins I use and why

  10. Hello!

    Thank you very much for this plugin. I needed something like that, because with more images it’s boring to add rel=lightbox all the time. :D

    Sadly, I think there is a conflict with one (I hope it’s one) plugin – Sitemap Generator from Dagon Design. I am opening my sitemap today and it was empty! WTF?! I tried few things, then I started to deactivate plugins one by one. It’s start working when I’ve stopped your plugin. :( Please, can you tell me what should I do to make them both work?

    Thank you in advance,
    S.

    • Hello,
      What are the other plugins used on your blog? Because I just tried with a local installation (WordPress 2.2) just Add Lightbox + Sitemap Generator and they work fine.

    • Hi again,
      I have lot of plugins actually. Maybe I should try to deactivate all of them and enable them again, one by one. And my WP version is 2.3.1, maybe there are some differences between 2.2 and mine version.

      I’ve switched between Lightbox 2 and Lightbox JS 2.03.03 plugins – same story.

    • Do you use Igallery Plugin?
      Can you try to only activate add Lightbox and Sitemap Generator and tell me if it work?

    • Hello,

      Sorry for the delay, I am not receiving e-mails on new comments. Anyway.

      I am not using Igallery plugin. I tried to deactivate everything, except your plugin and Sitemap – still got the problem with the « blank » sitemap.

      WP version is 2.3.1
      Add lightbox 0.1
      Dagon Design Sitemap Generator 3.12

      Off the topic: what is the plugin you are using for live comment preview?

    • Hi,
      I’ve just tested on WordPress 2.3.1 on a PHP: 5.2.2 (and Mysql 5.0.41, but this have no importance):
      Add lightbox 0.1
      Dagon Design Sitemap Generator 3.12
      No problem. It would be easy if I could reproduce the bug on my version.
      What is your php version? What occurs when you delete line 18 on my plugin? Can you make me a capture of the settings you use in the Sitemap Generator?

      For Live Comment Preview, I use Live comment preview ;)

  11. Hi pall, I just tested your plugin, and it works almost flawlessly :)

    The problem occurs when you have a URL, and on the same line, followed by a smilie (eg :) ), which is parsed by the WordPress engine.

    Then you then you get the following line:
    <a href="..."> </a>
    it matches from the first
    Thats bad, it needs to match from every , and when there is a .gif or … inside it, THEN you can parse.

    So I changed your pattern, just by adding 2 chars:
    Check it out:
    $pattern = "/<a>/i";
    to
    $pattern = "/<a>}/i"; (Added the {} around the > )

    I hope you update the package ;)

    Cheers mate

  12. Thank you, looks like the function I’ve always missed! Martin

  13. Hello, I upgraded to Lightbox 2.5 plugin for WordPress and also to plug Add Lightbox v0.2 and is not working properly Plugin Add Lightbox v0.2, since it does not add the attribute rel = « lightbox [XXX] » all the images.

    Greetings and I hope you have helped.

  14. Hi,

    I’d like to know where I could get you great Radioplugin (Widget?)
    Could you do me the favor and provide a link?

    BTW came over by looking for your lightbox plugin!

    Andreas

  15. Hi, thanks for the awesome plugin it’s working well on my site. I did have problem I hoped you could help me with though, if I use the « The excerpt reloaded » plugin to display excerpts on my main page and there happens to be an image that is shown in my post, the image link will not have the rel= »lightbox… » added to it. Would it be possible for you to add this functionality (adding the rel= »… » to all images, not just the ones in posts)? Thanks again for the great work!

  16. AndreasP :
    Here my christmas gift ;)

    Dan Luong :
    I’m not sure at all but can you try to add this line in the plugin:
    add_filter('the_excerpt_reloaded', 'addlightboxrel_replace');
    or
    add_filter('the_excerpt', 'addlightboxrel_replace');

  17. Pingback : Liste des plugins Wordpress 2.3 installés sur ce site @ Les élucubrations de Chacsam

  18. Thank you for the great plugin!

    I’m using it with ms_lightwindow beautifully, but I’d like to know how I can modify it to use the post name instead of the post ID as lightwindow uses the rel= » » tag to name the gallery in the galleries menu. I’m sure it’s a slight change, but I’m looking for advice on how to do it.

    Thanks again!

    • Hi Joe,
      That’s true, it’s a slight but as I know the plugin, it is easier for me ;)
      To do this, go to line 19 of the plugin and replace $post->ID by $post->post_title . That should work.

  19. Hello!
    First of all thank you for this great plugin, it really safes a lot of time.
    But I now come across a question: Should the plugin also work on the main page ? I mean if I have a picture on the main page showing an article and I click on the pcture it is odinary opened in an empty window. If I go into the post and read it from there your plugin shows the lightbox wonderfully.
    Is there an option how it would work too ?

  20. Hooray! Your fix worked like a charm for me! I should have been able to figure that out though. Thanks!

  21. cekay :
    Could you show me an example of what doesn’t work please?
    Joe :
    Glad I could help you ;)

  22. Pingback : Tage wie diese - Das Blog » Blog Archiv » Schon wieder was Neues ausprobiert ;-)

  23. Pingback : Christiaan Conover » Five Wordpress Plugins to Make Your Blogging Year Better

  24. Sorry, but I think it was caused from a plugin wich came in the way of lightbox. But i can’t remember wich one. I simply deactivated all plugins and put those needed ones one by one and now it works perfectly. Thank you!

  25. Pingback : Wordpress and automatically use slimbox for pictures | Philipp's braindump

  26. Pingback : Roger Brancucci » Blog Archive » Lightbox JS v2.03.3 Plugin Add Lightbox v0.2

  27. Thanks for a great plugin! Since I’m a lazy writer, I prefer to add as little extra code as possible. ;)

    Question: is it possible to create the same kind of automation for thickbox?

    • With only images, it is easily posssible : In the plugin, on the line 17 ( $replacement = ( … )

      Replace
      rel= »lightbox[%LIGHTID%]« 
      by
      class= »thickbox » rel= »%LIGHTID% »

      And it should work. ;)

    • Worked like a charm, thanks! ^^

  28. Bon, alors moi je suis peut etre complètement une tache mais ça ne fonctionne pas :°(

    • Tu peux me passer un lien pour me faire voir où ça ne marche pas?
      Pour rappel :
      – Le plugin doit bien sûr être activé
      – Ca n’installe pas Lightbox, ça ajoute seulement l’attribut rel= »lightbox[ID_DU_POST] »
      – Il faut faire un lien vers une image, et non pas seulement insérer une image dans le post.

  29. VERY stupid instructions…

    • Where are the stupid instructions? Let me know so I will be less stupid!
      Edit: and a fake email, so I can’t contact you! What a courage! You come on my blog, and you let me a unpleasant comment without explaining anything! It doesn’t give the desire of developing plugins if it is for having so pleasant messages

  30. Hi Mdkart,

    Firstly thank you for your plugin and your free work, it is very much appreciated from my side of the community. I also agree that the post VERY stupid instructions is just unhelpful.

    I have installed lightbox and it works fine, I downloaded today the latest auto plugin, I activated it and all is well. Due to the simplicity of how this works I was a little confused so for anyone who is confused as to what to do beyond the plugin activation here goes.

    1.Once all is installed and activated doe the following
    2. Create new page or new post
    3. Within new page or post add images selecting thumbnail from the image manager and make sure the link to file is selected
    4. Add some more till you are happy
    5. Save the page
    6. go to page and click any of the image and VOILA they are showing in lightbox and as a group AWESOME

    for the previous poster, lets see you right all that in french or german or italian and see if you are too stoopid stupid.

    My WP version is 2.3.1 and Latest everything.

    Merci and Thank You

    I hope this helps some else who is confused but not rude.

    • 200 OK

      OK

      The server encountered an internal error or misconfiguration and was unable to complete your request.

      Please contact the server administrator, postmaster@mdkart.fr and inform them of the time the error occurred, and anything you might have done that may have caused the error.

      More information about this error may be available in the server error log.