Using CCK to create image galleries
ronoxQ - March 15, 2007 - 15:30
The Gallery module is an excellent one. The only problem is, it can't be modified. If I want to add pre-existing fields to its node type, tough luck.
Would it be possible to recreate this image-to-gallery relationship using the CCK?

Sure...
Sure, if I were to make a gallery with a CCK type, I'd just use views and taxonomy to do it. I would suggest:
-Your first view would be a page that's the collection of galleries, all showing the latest image and gallery description. (these would be your taxonomy terms)
-Your sub pages would simply be views pages, showing all images of that taxonomy. Using contemplate here, you could style your teaser images (the gallery images) and your full nodes (when you click on the image in the gallery).
Seems like a pretty straight forward application of views and taxonomy working together.
agreed...
agreed... very good use of views, taxonomy and image. One thing that might throw people for a curve is the use of CSS to make the nodes in the view appear like a gallery (x number per row). you can accomplish by telling the view to display in list view, and then using CSS to float left all the items in the list, among other styles.
brilliant. i knew how to do
brilliant. i knew how to do this. just didn't put it all together in my head. thanks for pointing this out.
One hurdle....
After posting this, I realized there's one hurdle to overcome. I haven't been able to figure out how to get a list of Taxonomy terms out of Views. See the explanation here:
http://drupal.org/node/128085
-Bob Christenson
Owner/Designer, Mustardseed Media, Inc.
MustardseedMedia.com
Well, the problem is...
...getting permissions to work. With the gallery module, I'm pretty sure the gallery owner can decide who can add pictures to his gallery. CCK's nodereference tables (what I'd assume I'd use to add it to the gallery) doesn't have permissions like that. Ditto the Node Relativity module.
Could this be a place for arguments?
No, not between people, but a place to use the arguments function in views or Drupal in general.
I am new to Drupal and don't know enough to say for sure, but I recently added a context sensitive embedded view to my project nodes to show a selection of images associated with the active project node's name. This worked great and showed me some further dynamic possibilities were there that I had hoped for.
I am very interested in finding a decent solution for this as I am looking to implement an advanced gallery in Drupal myself.
I wonder if the current user name could somehow be passed on to a form field in an image node through some argument so that creates an automatic association with a gallery node matching the user name.
You can certainly use cck to create a gallery node type, views to create a gallery view that shows images associated with the gallery node name and possibly the usernode module to automatically create a gallery node for every user with their name on it which can then have images associated with it.
My work in progress on trying to implement similar features is at the address below.
http://www.disscamera.org.uk/index.php
So please, how did you
So please, how did you manage to create "Camera settings" fields on your image'nodes (for example on http://www.disscamera.org.uk/node/29) ?
Regards,
http://www.uniterre.com
Just added some CCK fields for each setting to a camera settings
...group.
It's not very elegant and requires manual input from the user.
I hope to get the exif module working but my hosting is configured as PHP4.4 and the site has been created like that, they do however have PHP5 but all files must be renamed .php5 or the php version can be reset to interpret using php5 for all php files but I tried this and my site disappeared so I unset it.....
http://www.disscamera.org.uk
Taxonomy Access
Now, I'm not sure, since I haven't thought thru it very long...but it seems the Taxonomy Access module could address this issue. Each gallery would be a taxonomy term, and taxonomy access allows users (based on their role) to be given permissions based on taxonomy.
Seems like a good match, but again, I haven't tried it out...
-Bob Christenson
Owner/Designer, Mustardseed Media, Inc.
MustardseedMedia.com
The problem being roles
The problem would be, though, that users creating the gallery would have to decide who was and wasn't allowed to create inside the gallery. That would probably involve giving them some administrator powers, which is a no-no.
How to make a first view?
I am currently trying to impliment this suggestion by BobChristenson.
I have no real concern about permissions like later posters since all users (a limited list of local paid up cub members) will be able to associate their images with any project or competition nodes and for individual user galleries I plan on having views collate them by author ID.
The problem I am stuck with at the moment is trying to figure out how I can create a Galleries front page which has a number of grids containing a teaser image, title and link to each sub-gallery. Each Grid wants to be dealing with a different way of collecting the images.
My planned page would be as follows:
Title: Diss Camera Club Galleries
Grid 1: Title: Galleries by User.
Grid of thumbnails with 1 random or latest image per user, with their name below with both image and username being linked to a seperate page view listing all the pictures by that user.
Grid 2: Title: Galleries by Project.
As previous grid but 1 image per project (project is associated to an image by node reference cck field) and linked to a view listing all pictures associated with that project.
Grid 3: Title: Galleries by Competition.
As previous grid but 1 winning image per competition (competition is associated to an image by node reference cck field and a cck field created to rate or delineate winners) and linked to a view listing all pictures associated with that competition.
My main headaches are :
1. How do I limit the number of nodes returned in the view to 1 or another specific number per user/project/competition?
2. How do I present three different grids (essentially views in themselves) in one page?
3. How do I get images, usernames, project titles and competition titles on this page to link to the subviews/galleries that they represent? Currently they seem to automatically link to either the specific image node or user profile etc.
Any help you can give would be much appreciated.
My work in progress is here:
http://www.disscamera.org.uk/galleries
P.S. Bob, I like the design of your mustardseed site by the way. Very neat and pretty.
first view
this is a stickler using cck & imagefield. How would you select "ONE" image from each term?
How to attach the view(s)?
I am also interested in a solution to attach a group of images to a node. I like the idea to use views but here is my question:
Suppose I have the view(s) in place. How can I attach that group of images (defined by the view) to a specific node?
try cck view module or paste view code into php field.
hope those help you attach views if you haven't figured it out already. The first would expose it to content creators the second might be less visible if users arent allowed to enter php code. You can also embed it into your php templates for a content type but I'm not sure for individual nodes - see http://drupal.org/node/124446 for more info and discussion on how to embed views.
Viewfield seems to be the
Viewfield seems to be the right solution for that. Although it's the same egg I'm trying to crack.
http://drupal.org/project/viewfield
Have a look at this handbook
Have a look at this handbook post:
http://drupal.org/node/144725 HOW TO: Create an image gallery using CCK and Views (not Image Module)
These forum topics:
http://drupal.org/node/144726 Forum redirection for previous post.
http://drupal.org/node/156287 Image Gallery with CCK and Taxonomy
Hope this helps. Arsène
My method
I think my method was pretty simple and I set it up pretty fast. It works really well for my setup.
I made a couple galleries with these criteria/features:
This is how I did it:
install and enable the following modules:
At this point you should have galleries with automatic thumbs and list of galleries.
I further customized the display by adding this line to my style.css file:
.view-content-photos .item-list ul li { background-image:none; list-style-type:none; margin:20px; margin-left: auto; margin-right:auto; padding: 20px; background-color: #eee; border: 1px solid #000; width:150px; text-align:center; }The name of my view for the gallery list is "photos" change it in the CSS to whatever your's is set to. This is just an example of a decent way to theme it, you should do whatever you want to make it look good with your theme.
I themed the actual Gallery with this (also in style.css):
.field-field-images div { margin: 20px; display:inline; }Here are some screenshots:
gallery list
gallery
viewing
Absolutely brilliant
I have been cluttering around with image modules and gallery 2. This solution is so simple that I really like it!!!!!!!!!!
I just added a view for all of the galleries from one user (mygalleries), for the rest, your explanation was the best! Thanks
The only problem I have left is that I use user node for the user's profiles and I would like to have a link somewhere in the user node to the mygallery page of this particular user. I am a bit stuck here. I guess I have to make a seperate view for this too. I would appreciate any ideas to point me in the right direction.
Again, thanks for this great solution!
I'm not sure how views would
I'm not sure how views would help with this. I would just setup the gallery as a child of the usernode (the same way you make a profile CCK node) and give users access to create, and edit their own "gallery" nodes.
Thanks for the tip: finally one gallery per user!!!
I used the node family option to set gallery as a child of usernode. Then checked the box in the gallery content type to "works with user node" (or something), setting the box above to 1 will then give you one gallery per user!!! Finally!!!
Thanks for the help.
great topic
thanks for the nodefamily tip, I'm going to try that out.
Looks cool. Can you tell me
Looks cool. Can you tell me ..
Does this method give a per user album ?
Will the users be able to create sub-albums or more than one album ?
Does it create a "My album" type link in the menu ?
Fashion
My method just shows you how
My method just shows you how to make a single CCK gallery node, and use views to organize them. It is an alternative to using "Image" and "Image Gallery" and taxonomies, which I feel is cumbersome. Also, you can edit how the actual nodes look (I have a gallery I made for a client that has a bunch of other information on the gallery page.) You can use this method with other techniques to get per-user stuff, etc. It's just a standard CCK node, so you can use it in views, with "Usernode" and anything else you can do with CCK. Look around for info on using CCK for profiles, or per-user, and you should get the info you need.
Can't get gallery photos to display
I tried this setup (I was doing one image per node and using views), but I can't get the photos to display correctly like yours do. I created a type called Gallery with Multiple Select checked, and created a node with 4 photos. I then created the view as specified, and I get the node on the views page, but I don't get them to line up like you have them on your "gallery" link in your post, and I don't get all of them to show up in Thickbox when I click on the picture. When I click on the gallery title, they are displayed vertically. How did you get them to display horizontally? Was that with CSS, or should it happen that way automatically?
Thanks.
Wonder95
Re: Can't get gallery photos to display
I did a default drupal install, and wrote the steps as I went, so yours should look exactly the same as the screenshots. No special CSS (other then what I included in the description, which you should put at the bottom of the style.css file for your theme) and no theming. It's just Garland, with the stuff in grey added to my style.css file.
If thickbox isn't working on yours, make sure you did the imagecache stuff right, and that the "display fields" stuff is connected to the right imagecache profile. Only one image shows in thickbox at a time. What you are seeing is one image (a long one.) I included this to show how it resizes irregular images.
More info please
I am very new to Drupal and your solution works perfect. However, I seem to be at a loss to create some additional functionality. I am able to create galleries just fine, but I would like to create a menu link that is only visable for authenticated users that shows all my galleries. For example, the menu link is labeled Photo Galleries ==> a page that lists links with years ==> a page that shows all the galleries for that year.
I hope that makes sense.
More info please
There currently isn't a way to make a menu from a view (that I know of). I wish there was, as this is something that I keep needing, for various things. Maybe I will write it. Looks like someone else needs this too.
all views can have a menu
Just simply create a new menu item manually which points to that views url. (you have to make sure the view provides a page url first)
These can then be organised and nested as you want.
Hope I understood the question.
http://www.disscamera.org.uk
No, what I mean is
Sorry, you are right, I misread the original post. Yes, you can easily add a menu item. What I mean is dynamically generate a menu from a view, which I think would be even more useful (for alot of other things, too.)
Like this:
Galleries (view) generates a menu of available galleries, based on the view (described above)
so the menu would look like this:
Galleries
Each of those items being a gallery. This way you wouldn't have to go to the in-between gallery page (click: Galleries menu item, then the gallery) just go straight to the gallery you want. This idea becomes way more useful when you are using nicemenus, or one of the DHTML menu systems.
There are alot of places for this sort of thing, once you start using CCK/Views alot. Another example would be a view created to list all "News" (a CCK type, that you could create) nodes, directly in the menu, or list just new News (if the view is set up that way.) From what I understand generating this on every page load is sort of expensive, but it seems to me that view caching should help with this. As far as I can tell, it shouldn't be any more expensive then using taxonomy. I'm still working on it. I am so busy...
Very easy - use "Summary View"
This is an old thread - but perhaps this will help someone...
To do what knosumer want, you simply choose an "Argument" for the View. This will essentially build a set of views, one for each value of the argument AND provide a summary page that lists all possible values of the argument with a link to that view.
For example, if you wanted a per-user photo album - easy. Simply set up the View for a generic photo gallery (say a grid view, showing image thumbnail and title with links or Lightbox, or whatever) and then add the Argument - Node:UID is Author. Select "Summary, sorted ..." and put "%1's Photo Album" for the Title (%1 is the first argument, which will be the Author's ID!)
You could create a set of galleries based on a Taxonomy the same way - simply use the Taxonomy Term as the Argument, and select Summary. Again, the summary page will list all the taxonomy terms with links to each "gallery".
I think this is actually the most flexible and easiest method of creating image galleries, as the images reside independently from the gallery, and can thus be organized and displayed in a variety of different ways (e.g., by user, by subject, by date, etc.)
For more info, see Views Arguments: http://drupal.org/node/54455
The problem I am having, and I'd REALLY appreciate some advice on this, is that the summary page is very plain and ugly. I want a summary page that is formatted like the old Image Gallery module summary page. But I haven't found a nice, flexible way to do this yet.... still searching....
good luck.
Thank you, this will help me
Thank you, this will help me and other drupalers a lot. Come back if you get your answer :)
Display the summary view as a "mock-menu"
Here it is - as usual, someone else has already done all the heavy lifting:
Example: How to Display a Summary View as a Mock Menu http://drupal.org/node/42605
Now I want to pull the latest image and taxonomy descriptions for my gallery listing page... hmmmm.
This is exactly what I was looking for
If you get the 'latest image' part worked out I will forever be in your debt!
Sorry - my misunderstanding
A summary view won't actually help with knosumer's method, because the whole gallery is only one node - the gallery node. A summary is useful for summarizing over taxonomy terms or over users, or whatever - does not apply here.
Konsumer's gallery is VERY simple to configure and get working. But it is important to understand the potential drawbacks of this method too.
Here's why Konsumer's method won't work for me:
You might find a recent post of mine of interest: http://drupal.org/node/176252#comment-741225
Yep, there are several ways to accomplish "CCK galleries"
It's just one way to do it, that works for alot of situations, where I need a nice-looking gallery, fast, and I don't care about any other data. It seemed like people have alot of trouble with this, so I explained how I "slap a gallery on there" in about 5 minutes. If more is needed, it's really easy to accomplish.
1. You can also make gallery by making a content-type for your image, and only allowing a single image in the image field. Use a view to create the gallery (copy the instructions I gave before, but now it's a gallery, not a "gallery summary" view.) This allows you to add any CCK fields you want to the content-type, not just title and body. This is also a fine solution, if you need the other data.
2. There are lots of ways to slice and dice, you can use view blocks, tiny bit's of PHP in the block messing with the field data, or whatever. I'm not sure I understand how there is an alternative, or what other methods have to offer over this approach. You have as many options as you do with any other solution, and more then some.
3. #1 also solves this problem, if this is a problem.
4. This is true for every other gallery system that I have seen. Using the method I describe in 1 allows the use of standard node import/export, though, so it's actually better for me then using the image module method still, because If I am migrating, I already have file-table and node-content imports worked out (using imagefield, CCK, and views in everything has definite advantages over custom modules and disjointed content-types for everything, even if just to modularize data-migration.)
I'm not sure I understand what you are proposing instead of this, as taxonomy-based solutions, and custom-module based solutions have all the same drawbacks that you speak of. It sounds like you simply need to think about the problem differently, and my solution might still be helpful (like try the suggestion in #1)
ok...
Believe me konsumer - I'm not knocking your method - it is so so so simple and easy to set up, and that is just what a lot of folks want - that makes it a beauty, and obviously been of value to lots of people. I was simply addressing the concerns of one user who seemed to want to do more with the images than simply display them in a gallery. I was just trying to make readers aware of the trade-offs they are making when choosing one data structure over another.
The modified solution you propose in (1) is more along the lines of the approach I'm taking. The image data now has an "independent" existence and can have its own meta-data, be sorted, searched, and tagged, can be displayed in a variety of Views, etc. And, if you ever want to use a different approach, you won't need to re-upload all your images. This nicely addresses all the issues I raised, but people need to understand that this is a totally different approach, and is exactly what I was trying to get across in my post. Your original method puts all the image data into a single gallery-type node with a multi-value image field. Your proposal in (1) puts each piece of image data into a separate image-type node and uses a View to generate the gallery. These are incompatible methods - once you choose to do one, you simply can't change your mind and switch to the other without re-uploading all your image data. That's the point, which may be obvious to you, but may not be to all.
One other requirement I had for my galleries was that they would "automatically" add new photos that were uploaded by users. I wanted both by-category and by-user galleries. The only approach I've found flexible enough to give me this is a Views-based gallery. While perfect for my needs, this may be totally overkill for some, and hard to understand for new users.
For example, the issue I'm struggling with, which led me to your post, is how to get a nice "summary" view of all the galleries that shows the last date modified and image added to each gallery, etc. (similar to the old Image module Image Gallery display) - I think I've finally resolved that one, but it required custom programming, so definitely not for everyone.
I have spent a lot of time struggling with the issue of creating a flexible approach to photo galleries. I actually really liked the taxonomy-based approach in the Image module, so I've been trying to replicate that using CCK imagefield (which really is a big improvement over the Image module, but not as well supported in terms of polished modules). There are literally dozens of approaches and custom modules out there to create CCK image galleries - each of them has strengths and weaknesses. Hopefully one day I'll get the time to write a handbook page about my trials & errors, as it seems a lot of people struggle with this issue - and many likely end up choosing an inappropriate method, creating loads of work later when their requirements change.
Did you find a solution to
Did you find a solution to the problem of summary page looking ugly?
I did create a summary page using Panels and adding views to it, which works well enough apart from if the user clicks any of the images of the galleries, instead of going to the gallery, thickbox comes up, but only allows them to go between the images displayed. Not found a way to stop this happening or force going to the actual gallery upon the image being clicked.
Yes...
I created a custom summary view to imitate the Image module's Image Gallery - it looks and works very nicely.
http://lasqueti.ca/books/design-notes/image-gallery-summary-view
Currently, Views does not support 'plug-in' summary types, so this will need to wait for Views2 to be developed into a real module... currently, you need to provide an override in template.php - detailed instructions and documentation are included with the code.
good luck.
Uff, just thank you. This
Uff, just thank you. This implementation has exactly the flexibility I was seeking for. Wasted few days for researching on this topic.
However, there is a question
However, there is a question rising, is it possible, somehow, to make thickbox.module be aware of imagecache generated presets, like its implemented with image.module, so thickbox will display let say preview800x600 rather then original 1Mb file (example)?
Answer to myself is in this
Answer to myself is in this post http://www2.drupal.org/node/179386
Reordering?
Is there an easy way for the admin user to reorder images within the galleries?
Ordering is desperately needed
See this thread http://drupal.org/node/113259 - it actually appears to go nowhere but is all about ordering multi-values within cck - Anyone know how to do this??
I doubt you can...
See my comment above: http://drupal.org/node/128080#comment-742237
Does this work in the 6.x
Does this work in the 6.x version? :) Because I don't remember some of those modules being "out" in the 6.x version. :)
Choosing thumb
(first thing : excuse my english)
On your screenshots, it seems to be the first image of the gallery which is used as thumb. (it might be set in your Gallery View > Fields > Image:Images > Show first value only)
But is there a way to choose which image have to be used as thumb for each gallery on the Gallery View ?
I worked on this for days whithout finding any solution. :/
Regards,
Didn't read all the comments
Didn't read all the comments above, but there is a great video tutorial here:
http://www.theartlab.net/files/drupalschool009.m4v
Uses, CCK Image, Views, Imagecache, and a few other things.
Adding a search option
I just posted this in drupal post installations, but this might be a more appropiate place to post. I was wondering if there was a way to add a search function to this type of views cck gallery?
thanis
If the galleries are created
If the galleries are created and based upon taxonomy, then searching by term would be possible.
alternatively, there is faceted search, for which also exists a cck module to expose cck fields to it. not tried it personally though.
subscribing
subscribing
subscribing