Technologie

The Morning After – Galleries, anyone?

Since version 2.5, WordPress offers built-in galleries. I want to use this new functionality for:

  • adding galleries to posts
  • having a gallery overview page.
  • having a latest gallery section on home.php

Therefore, I have to do some modifications to Arun's The Morning After theme (that I am using here).

image.php

For using the new gallery functionality of WordPress 2.5, the theme needs a a new template file. This template file is called image.php. Due to the fact that The Morning After does not include the image.php template (yet), I have to create it by myself.

Therefore, I have copied image.php of the default theme into the directory of The Morning After and modified it so that it matches TMA.

The most relevant code is here:

image.php

For the full image.php template file, please click here

Thanks to Michael Fields, I was able to substitute the large thumbnails by text links. The text links nb_previous_image_link( '« Vorheriges Bild' ) and nb_next_image_link( 'Nächstes Bild »' ) require the following code in your functions.php:

home.php

For copy&paste, click here

home.php

For the "Latest Galleries" section on the starting page of this weblog, I am using the following code:

home.php

For copy&paste, click here

gallery.php

And for the gallery archive, I wrote the following page template:

gallery.php

For copy&paste, click here

Then, I have added the following variables to the style.css:

style.css

For copy&paste, click here

Conclusion

With these modifications, I ...

  • can add galleries to posts - Example
  • have a gallery overview page - Here
  • having a latest gallery section on home.php - Here

UPDATE! This version of the image.php is not compatible with WordPress 2.6. Please use the basic version without text link navigation or apply the fix that I have posted in the article about upgrading to WordPress 2.6.

Diskussion

29 Kommentare für “The Morning After – Galleries, anyone?”

  1. Thanks for telling us. I’ll give it a try locally on my computer.

    Geschrieben von ket | Mai 15, 2008, 15:33
  2. Hello,
    It’s me again. I’m very impressed with your gravatar. Will you write tutorial of how to integrate it to your site?

    Geschrieben von ket | Mai 15, 2008, 15:40
  3. Geschrieben von Nick Bohle | Mai 15, 2008, 16:09
  4. Hi Nick, I need some urgent help from you. I tried to do the above process and my WP is gone :( As soon as I copied the image.php and tried to move to the next page, I’m seeing only blank pages. You can see at http://ubiquitense.com/wp-admin. and also, my site doesn’t come up if I type http://ubiquitense.com

    Thanks in advance!

    Geschrieben von Ubiquit | Mai 16, 2008, 19:20
  5. well, I solved it myself…jus replaced the functions.php with the original one. phew!!! that was close :)

    Geschrieben von Ubiquit | Mai 16, 2008, 19:26
  6. Ohh!!! Strange error… As you see on my site, I have no problems with the code!

    Geschrieben von Nick Bohle | Mai 16, 2008, 19:31
  7. Could you please forward me the functions.php to gigatech2006@gmail.com?

    Danke!

    Geschrieben von Ubiquit | Mai 17, 2008, 12:10
  8. You’ve got mail! Let me know if you still have problems..

    I’ll tell you a solution without the functions.php then.

    How do you say “you’re welcome” in Madras?

    Geschrieben von Nick Bohle | Mai 17, 2008, 12:25
  9. Hey Nick, I found this http://wordpress.org/extend/plugins/nextgen-gallery/, and ‘ve implemented it. It’s quite cool, and may be you wanna try it.

    You can see it on my site http://ubiquitense.com/ and click on Gallery

    Geschrieben von Ubiquit | Mai 18, 2008, 11:13
  10. Not bad. But I prefer a no further plug-in solution.

    Geschrieben von Nick Bohle | Mai 18, 2008, 11:31
  11. Does usage of plugins slow down the site? well, I found it attractive because ‘m not good at coding :)

    Geschrieben von Ubiquit | Mai 18, 2008, 13:49
  12. Yes, some plug-ins do slow down the site.

    But this is not the main reason why I say the less plug-ins the merrier.

    My main reason is that I do not want to depend on plug-in authors when I upgrade my WordPress installation.

    For example, NextGen Gallery was not compatible with WP 2.5 when the new version came out.

    Geschrieben von Nick Bohle | Mai 18, 2008, 14:05
  13. Oh yes, you’re right. Anyways, ‘m quite slow in upgrading to the latest WP versions..I just watch for more than a month and later upgrade when all plugins are ready for the new version :)

    Geschrieben von Ubiquit | Mai 18, 2008, 14:36
  14. Ein weiteres Mal hat mir Deine The-Morning-After-Reihe sehr geholfen. Vielen Dank!

    Geschrieben von fab | Mai 22, 2008, 20:59
  15. Momment: So wie es aussieht hast du einen Tippfehler in der home.php line:
    img src=”/images/thumbs/

    der slash zwischen dem “?” und dem “>” nach dem stylesheet muss weg.

    Geschrieben von fab | Mai 22, 2008, 21:29
  16. Ein letzte Mal noch (es tut mir leid): Ich schaffs nicht, neuen Kram der Bilder-Kategorie aus den latest_post zu halten. Irgendeine Idee?

    Geschrieben von fab | Mai 22, 2008, 21:52
  17. @fab:

    I’ve exchanged the code with images… Arrghh… always have problems with displaying code.

    About exlcuding the gallery category from LATEST POSTS, RECENT POSTS and the CATEGORY LIST, you have to:

    • Open home.php and sidebar.php in your visual theme editor.
    • Then you add the following line (cateogry called Gallery) according to the lines for ASIDES and FEATURED:

      php $catid3 = $wpdb->get_var(“SELECT term_ID FROM $wpdb->terms WHERE name=’GALLERY’”);

    • Then, add ,-’ .$catid3. ‘ to queries of the LATEST and RECENT POST sections and ,’ .$catid3. ‘ to the exclude part of the wp_list_category function (sidebar.php).

    DONE.

    Geschrieben von Nick Bohle | Mai 23, 2008, 10:30
  18. Thank you very much! Problem fixed. I forgot the recent post section…

    Geschrieben von fab | Mai 23, 2008, 15:53
  19. [...] Since version 2.5, WordPress supports built-in galleries. So, I have added a gallery archive, a gallery section on home.php and an image template to my customized version of THE MORNING AFTER. The tutorial can be read here. [...]

    Geschrieben von The Morning After - Images, anyone? | nickbohle.de | Juni 1, 2008, 11:03
  20. Nick,

    Thanks for this. I have one question? How do I incorporate the gallery overview php file into a page? Or what do I need to do to set up the gallery overview page? I can’t seem to figure that out.

    Do I create a page that incoporates the .php file?

    Thanks

    Geschrieben von Lee Hoover | Juli 7, 2008, 17:47
  21. Nick,

    Thanks for this. One question though? How do I set up the gallery overview page? I see how to create the .php file, but how do I incorporate that into a page? Everything else I can figure out, but that seems to lose me.

    Geschrieben von Lee Hoover | Juli 7, 2008, 17:49
  22. Hi Lee!

    Ohh.. Sorry… Forgot to write about this…

    Well, you upload the page template “gallery.php” into your TMA folder. Then, you “write a page” (all you need to do is inserting the title and applying the template to the page. click publish) and you are done.

    Geschrieben von Nick Bohle | Juli 7, 2008, 18:00
  23. Danke Nick! I learn something new everyday. Sorry about the double comment…didn’t realize the first one went through.

    Geschrieben von Lee Hoover | Juli 8, 2008, 00:07
  24. Hello Nick,

    One more question, and I swear I’ll stop bugging you. Do you know how to change the variables to the thumbnails? I’d like them to be proportioned to the actual photo, not perfectly square. Where is the CSS for the actual pic thumbnails?

    Thanks
    Lee

    Geschrieben von Lee Hoover | Juli 8, 2008, 12:29
  25. Hi!

    Go to:

    WP Dashboard > Settings > Miscellaneous

    and deactivate “Crop thumbnail to exact dimensions (normally thumbnails are proportional)”

    This change will only effect new uploads.

    cheers

    Geschrieben von Nick Bohle | Juli 8, 2008, 16:03
  26. You’re My Hero

    Geschrieben von Lee Hoover | Juli 9, 2008, 02:03
  27. [...] the text-based navigation for your the image.php template that I have proposed in this tutorial is not compatible with WordPress [...]

    Geschrieben von The Morning After - WordPress 2.6, anyone? | nickbohle.de | Juli 11, 2008, 13:50
  28. Hello Nick

    I love your customizations to the TMA theme and have been working with it to develop my site. I thought I mention that the gallery.php code on this page has an error which forces the galdescription box below the sample image. I found it was caused by an improperly named style – .set when it should be .galset – as shown below

    <!–
    <a href=”">
    ID); ?>

    –>

    Thanks!

    Geschrieben von Richard Meagher | August 15, 2008, 04:07
  29. Thanks Nick, for sharing your codes and templates! Peace.

    Geschrieben von mercime | September 1, 2008, 06:46

Kommentieren

Mit dem Absenden Ihres Kommentars willigen Sie ein, dass der angegebene Name, Ihre E-Mail-Adresse und die IP-Adresse, die Ihrem Internetanschluss aktuell zugewiesen ist, von mir im Zusammenhang mit Ihrem Kommentar gespeichert werden. Die E-Mail-Adresse und die IP-Adresse werden natürlich nicht veröffentlicht oder sonst weitergegeben. Weitere Informationen...