Experimental project
This is a sandbox project, which contains experimental code for developer use only.
The Simple Image Gallery is the first module I've created. I am publishing it as a way for other Drupal developers to learn some of the basics about module development. This can be used in a production environment, but isn't recommended since it has a few redundant areas.
Download:
git clone http://git.drupal.org/sandbox/KurtKnudsen/1858534.git simple_image_gallery
What it does:
Upon installation it creates a Content Type with an Image field. It sets the Image Field to 'Hidden' so it doesn't show up on the node. It also sets the field's Image Style and Image Link via code, but since it's hidden, it's rather pointless. It also creates an Image Style of Scale&Crop at 75x75 pixels. Lastly, it creates a Views page to display the content at ?q=image_gallery.
You can upload an unlimited number of images when you Add New Content. When you click on a thumbnail image, it will open a larger version next to it in a display div. It uses simple Javascript to accomplish this. I was going to use AJAX but that was far more complex than it needed to be. The JS hooks into the click() event and grabs the image source from the anchor tag.
What you can learn from it:
- How to create a content type
- How to create and setup fields for a content type
- How to display the content type in a Views page
- How to theme the output of the node via templates
- How to use Javascript to replace the content of a div
- How to use CSS to style the content
Notes:
I make no claims that this is the best way to go about creating such a simple module, but it helped me learn a lot about the different aspects of Drupal.
Credits:
Much of the base code is from the node_example.module file from the Examples package. The CSS/Template files are modified from Galerie, so please check out his module for a more fully-featured image gallery.
Dependencies:
Project information
- Created by KurtKnudsen on , updated