WordPress: Nextgen-Gallery single pictures with captions

For sets of pictures I like the NextGen-Plugin (nextgen-gallery). It allows very easy gallery views of pictures and – what is also important – the internal media library of WordPress in enhanced by the thematic storing of the pictures.

In practice this means I often use pics from galleries also as single pictures in articles. Nextgen-Gallery has a [ singlepic ] feature, but unfourtunately it doesn’t show captions. That’s realy sucks.

A web search shows me the principle how it canbe solved but I didn’t found a ready to use solution that looks OK. So I write my own and provide it to a free usage.

My solution: Use the singlepic-caption.php from the download below and add your image as follows to the article (remove the spaces befor and after the square brackets:

[ singlepic id=2 w=320 h=240 float=none template=caption ]

The template=caption statement lets use the singlepic-caption.php instead of singlepic.php

In my template the text from the title-field is used as caption. In the fullscreen view the normally longer text from the description field is used.

For a besser separation from the normal text the caption is one step smaller than the normal text and set in italic. I also add an additional vertical space to separate the image better.

It looks like this:

Jahreswechsel 2010/2011: Der Winter schlägt richtig zu

Jahreswechsel 2010/2011: Der Winter schlägt richtig zu 

I haven’t translated the german caption in this example, so that the link to the image from the input mask get not lost. The caption means: “The Winter 2010/2011 was unusual heavy”. And the long version in the full screen: “Because of the snow the streets have been made to one way streets, but for all that we don’t know where to bring the whole snow.”

The template can be downloaded here:

Download

It must be extracted and copied to /wordpress/wp-content/plugins/nextgen-gallery/view/ . And these must be done also after every update of nextgen-gallery because the update deletes the whole directory.

Update January 2014

NextGen-Versions from 2.x is no longer compatible to this (and many other) add-on. If you want to use the singlepic-caption template and/or if you don’t want to edit all your past posts, please use the NextCellent gallery instead.

Update December 2014, Version 1.1

Adapted to the newest version of NextCellent-Gallery
Solved a problem with getimagesize and disabled “allow_url_fopen” option in the php.ini

This entry was posted in IT and tagged . Bookmark the permalink.

18 Responses to WordPress: Nextgen-Gallery single pictures with captions

  1. Hi Ralf,

    funktioniert deine Vorlage für Bildunterschriften noch immer mit der aktuellsten Version der NextCellent Gallery? Bei deinem Beispielbild im Post scheint die Bildunterschrift zumindest nicht mehr angezeigt zu werden.

    Würde mich über eine Antwort freuen.

    LG

  2. Sascha says:

    Hallo,
    funktioniert diese Lösung auch mit dem neuen Release NextGen Gallery 2.0?
    Viele Grüße!

    • Ralf says:

      Nein, leider nicht. Photokrati hat das Plugin auf eine völlig neue Basis gestellt und die alten Sachen funktionieren nicht mehr. Schlimmer, bisher hat man eine Dokumentation zum Erstellen kompatibler Plugins zwar angekündigt, aber noch nicht bereit gestellt.

      Wenn es für ein Plugin so viele Ergänzungen gibt, kann man das doch nicht einfach ohne ausreichenden Vorlauf für die anderen Entwicker inkompatibel machen .

      Wer schon in die Updatefalle getappt ist: Bitte hier weiterlesen.

      • Tobbi says:

        Danke für den Hinweis, also besser warten… 🙂

        • Tobbi says:

          Hi Ralf,
          hast Du in der Zwischenzeit die aktuellste Version (2.0.40) nochmal daraufhin überprüft, ob es nun möglich ist, dein Template wieder zu verwenden?

          • Ralf says:

            Hallo Tobbi,

            nein, es hat sich noch absolut nichts getan. Ich muss nochmal eine Mail an Photocrati schreiben, mache mir aber eigentlich keine Hoffnung auf eine substanzielle Reaktion. Ich stehe auch mit anderen Nutzern in Kontakt, die ähnliche Hacks gemacht haben, aber bisher hat noch keiner eine Lösung. Wenn man das Nextgen-Support-Forum liest, wird einem auch schlecht. Probleme über Probleme. Zur Zeit klagen viele über massive Performance-Einbrüche durch eine Datenbankabfrage. Auch ohne das singlepic-caption Problem ist die neue Version aus meiner Sicht noch keine Alternative.

            Es gibt jetzt einen Fork der alten Nextgen-Gallery-Version, der sich NextCellent-Gallery nennt. Ich habe diesen soeben installiert und damit funktioniert alles wie bisher. Ich werde wohl dabei bleiben und Nextgen löschen. Aber unbedingt die FAQs zu NextCellent zu Ende lesen und keines dieser Plugins automatisch deinstallieren. Das löscht die Gallery-Datenbank. Ich schreib dazu vllt. noch mal einen ausführlicheren Blog.

          • Tobbi says:

            Hallo Ralf,

            danke für den Hinweis mit NextCellent-Gallery, schaue ich mir mal an.

            Schade, dass das so nicht klappt und man das Plugin so zerfrickelt hat 🙁

  3. Chris says:

    Hallo Ralf,

    super Sache – und mittlerweile erscheint Dein Post bei Google auch schon schön weit oben 😉
    Mein Problem ist, dass für das Bild ein weißer Hintergrund über die ganze Breite des Textblocks “reserviert2 wird. Auch wenn ich über Angabe von w=200 das Foto deutlich kleiner mache…
    Das foto bilde ich wie folgt ein (auf “h=” verzichte ich):
    [singlepic id=32 w=200 float=none]

    Grüße,
    Chris

    • Chris says:

      Noch was: es tritt nur mit float=none auf. Ich kann mir ungefähr vorstellen, was hier passiert, nur habe ich von PHP leider keinen blassen Schimmer 😉
      Grüße,
      Chris

  4. Horst says:

    Hi, super Sache.
    Nur, wie bekomme ich das hin das es automatisch so erscheint ohne das der Anwender von Hand “template=caption” eintragen muss?
    Geht das überhaupt?

    • Ralf says:

      Das sollte rech einfach gehen. Die Standardvorlage ist singlepic.php Wenn man diese durch das hier vorgestellte singlepic-caption.php ersetzt, hat man immer die Bildunterschriften.

      Ralf

  5. Sascha says:

    Hallo,
    super Anleitung. Genau das, was ich gesucht habe. Ich möchte allerdings die Schrift verkleinern. Hierzu habe ich in der singlepic-caption.php den Wert für “font size” auf ‘-2’ gesetzt. Jetzt habe ich das Problem, dass die Schrift zwar kleiner ist, der nachfolgende Fließtext jedoch einen “riesen” Abstand hat. Kann man das irgendwie anpassen?
    Vielen Dank! Sascha

  6. Daniel says:

    Thank you so much! This was exactly what I was looking for! More people need to know about this! Thanks for sharing!

  7. Klaus says:

    Das Thema habe ich auch beschrieben und auch einige Zusatzmöglichkeiten
    Die Infos findet ihr hier:
    Ich hoffe es hilft einigen!”

  8. Sady says:

    Irgendwie war mein Versuch nicht von Erfolg gekrönt, eine Bildunterschrift wird irgendwie nicht angezeigt :/

  9. ralf says:

    Danke für den Kommentar.

    Ich mag ehr große Bilder und verwende daher float=right nicht wirklich.

    Ich befürchte, man muss hierfür tiefer eingreifen und eine eigene CSS-Klasse schreiben. Ich denk mal drüber nach.

    • ralf says:

      Gelöst.

      Man braucht die Bildgröße, die nextgen-gallery als Artikelbild einfügen will. Mit etwas Reverse-Engineering war das dann doch zu machen.

      Danke RsVe für den Anstoß hierfür.

  10. RsVe says:

    Hallo,

    sehr schöne Sache. Leider habe ich ein Problem mit deinem Code. Wenn ich das Bild zum Beispiel rechts im Text platziere, bleibt die Beschreibung links, während das Bild nach rechts rückt. Gibt es dafür eine Lösung?

    Grüße

Leave a Reply to RsVe Cancel reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.