Development blog about PHP, HTML & CSS and Drupal

Create an album based image gallery in Drupal 7 using fields and views

Nice Job! Thanks for the tutorial

Nice Job! Thanks for the tutorial. Can you make this an exportable feature & share it? THANKS -Austin-

Good idea, as requested -

How to make it sortable..

Great tutorial ! I was wondering how to add sortable buttons in the header of the view as you can see in this example : http://demo.themesmania.com/converge/portfolio In this cool portfolio-example the author used taxonomy terms to create the buttons and some jquery to get the great result. I wasn't able to figure it out myself. (All I was able to do is add some jquery with the media module as you can see here : http://drupalthemeplayer.com/node/1)

Do you know how he did this in drupal 7 ?

Johan

I actually saw a jQuery

I actually saw a jQuery plugin that did this a few days ago via Twitter but I can't find it now.

The following 2 tutorials teach how to do it though:

THANK YOU!

This was extremely helpful, thank you very much, Jason!!

Sajid

Fantastic tutorial mate!!

Awesome tutorial! I do have

Awesome tutorial! I do have one question though; about the individual gallery pages. So I set up the gallery content type gallery, but it's not very pretty. Is there a way to customize the layout of each gallery with views or something? Thanks for any help!

In Drupal 6 I used the Panels

In Drupal 6 I used the Panels node template to display a view rather than using the content types node-type.tpl.php.

Similar to this but using node template rather than taxonomy. Then in views you would do the grid layout with an argument of the node NID from the URL and make sure the images field isn't grouping images.

Thanks for suggestion, but I

Thanks for suggestion, but I cam up with a slightly different solution (without using Panels, yay!). So in the galleries views, I made the text and image link to another custom view *instead* of linking to the physical node (I basically try to remove all references to the physical node, as it would just confuse people). That custom view contains a path argument of "gallery/%" and a "Content: Nid" contextual filter to pull the node ID from the URL, of course! And as far as the layout goes, I found that I prefer the content displayed as an unformatted list with no grouping, and the format should be set to fields. Then, in the fields, I have the title of the gallery and the images are displayed with just a space as a separator. Pagination set to 12 images per page. Since I didn't need comments or a direct way to edit a gallery, it's a pretty simple solution.

I would have liked to use a grid, but when I set the format to that, the images are all put into the first grid space with the other ones showing up empty but still visible. Any reason for this?

Thanks for all of your help again!

I guess there may be a

I guess there may be a setting within Views that you are missing. Perhaps you have grouping enabled?

Your solution works but isn't one that I would go down unless you sort out redirection of the node/[nid] URL otherwise you could get penalised by Google for duplicate content.

If you want a bit more control over the layout of your page, try Semantic Views which allows you to define your own HTML markup for the display which not only cuts down on the HTML produced which makes the page smaller but also allows you to style it your way.

argument of the node NID?

Could you be more specific on how to write the argument of the node NID? I have no idea where to start with the code for writing that. I need my images to break into multiple rows, rather than one long column, and have been at this for days. Please help! A detailed tutorial would be great.

I have written another

I have written another tutorial on doing this here

Where is the "buy me a beer"

Where is the "buy me a beer" button on this site? :) Thanks a million James, thanks a million ..

-iS

Thanks!

This is a fantastic tutorial for Drupal noobs like myself! Thank you so so much!

doubt

I am newbie plz tell me where to upload the photo........

Content > add content

Content > add content

Layout in album

I love the setup, it totally works... but how can you get multiple columns within an album?

Best done through your theme

Best done through your theme with a custom node-gallery.tpl.php or you could use a panel override for the node view and put a view in that panel that uses the node id as the argument with the grid view selected.

Alternatively, the simple solution would be to add a bit of CSS.

One step missing

Great tutorial, thanks. Under "setting up the content type," you don't say what choice we should make for "Widget." I am guessing ... "Image"?

Yes, it does say: "Under Add

Yes, it does say:

"Under Add new field, enter Images in the label box and images in the name box. Under Field, select Image. Press Save."

Four things

>> Yes, it does say: "Under Add new field, enter Images in the label box and images in the name box. Under Field, select Image. Press Save."

There are four fields to fill out, not three: Label, Name, Field and Widget.

I will update the tutorial

I will update the tutorial but most people won't have anything else under the Widget field unless they have some other module installed.

The Four Fields

>> Yes, it does say: "Under Add New Field, enter Images in the Label box and Images in the Name box. Under Field, select Image. Press Save."

It does indeed say that but there are four fields to fill out, not three: Label, Name, Field and Widget.

Gridless Gallery

Great tutorial, thanks. So when I go to the actual gallery, the thumbnails are stacked vertically, not arranged in a grid. What am I doing wrong? Or am I not doing enough.

You aren't doing enough but

You aren't doing enough but only because the tutorial doesn't go on that far.

There are a few ways of achieving the grid for the actually gallery node.

  • Create a view with an argument using the node ID and add this to a panel override of the gallery node type.
  • Create a node-gallery.tpl.php in your theme and theme it how you want
  • Change the HTML output in your template.php file
  • Use CSS to float the images to make a grid like layout.

What CSS do I edit?

Which CSS file do I edit? I am trying to get the images to appear in rows when the album is clicked on, and honesty I am a noob with css, so I am have a tough time trying to figure out how to make the images appear in rows instead of a never ending column. Please help!!

Your themes CSS file. You

Your themes CSS file.

You may also want to look at Display Suite

It nice

Hi thanks you so much i done with it. But how can i Scale And Crop images in thumbnails. Because my images resolution is not the same so when i view is look not good.

Any ideas thanks

You will need to set up a new

You will need to set up a new image style like you would with Imagecache in Drupal 6.

galleriess

thanks for tutorial.............

galleriess

thanks for tutorial.............

Excellent tutorial

Thanks for providing such a clear lesson.

Great tutorial

Thanks for this. Perfect!

Nice tutorial

Do you know maybe why I don't get Multiple Field Settings option when I'm adding image field in views?

When you created the field

When you created the field did you set it to allow more than one image?

multiple images upload

hi there, first of all thnx for this great tut.

only i`m missing the option to upload multple images at once. i`m searching for this option for so long but can`t find it :(

do you know an solution for a bulk upload?

1 picture at the time, is a lot of work on bik albums/galleries

i realy hope you have an answer for it

http://drupal.org/project/ima

http://drupal.org/project/image_fupload but it only appears to have a D6 release.

great job..

its very simple as anything..