Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mark Theunissen’s picture

Yeah it would be possible, but I'm not going to be supporting this. Patches welcome.

Mark Theunissen’s picture

Status: Active » Closed (fixed)

I'm just working on the code again and I realised that you could do this relatively easily by overriding some variables in a custom preprocess function. Here's the original for you to override:

function template_preprocess_galleria(&$vars) {
  $files = $vars['node']->files;
  $images = array();
  $i = 0;

  foreach ($files as $file) {
    $images[] = array(
      'data' => theme('image', $file->filepath),
      'class' => $i == 0 ? 'active' : '',
    );
    $i++;
  }

  $attribs = array(
    'class' => 'gallery',
  );
  $vars['gallery'] = theme('item_list', $images, NULL, 'ul', $attribs);
}


ica’s picture

Hi Mark, thanks for your reply but I am not a PHP coder,
so what is the diff to try to patch with this original code? that you pointed on line 86 after the

* Preprocess the galleria variables.
on the galleria.module

Mark Theunissen’s picture

To be honest, this module is still a 'developer's preview'. I am changing the API functions constantly, therefore if you're not a developer I don't recommend that you use it.

When the code becomes mature I will make a proper release and then you can download it!

ica’s picture

Thank you for your explanation Mark, I will keep eye on for the proper release

q_man’s picture

I too would love to see this work with CCK Imagefield, more specifically with output from Views which contain CCk imagefields (with images stored in a secure directory about the public folder on the server), including summary versions of those views for my current project.

The galleria demo is so beautiful I would love to have my site look like that - current project here: http://www.disscamera.org.uk

As you can see it's ugly and many views I can't even get to show the images or a single example of them for a particular person/ tag or competition when I want them to.

I might be able to raise some bounty/ pay some sponsorship if you can help me with this though it is a small non profit club we could probably scrape up some funds.

Mark Theunissen’s picture

One of the reasons I chose to work with Upload module instead of ImageField module is because ImageField is still in alpha.

When it becomes stable, I'll reconsider it... sorry, I don't really have the time otherwise..

iaminawe’s picture

subscribe

roger6106’s picture

subscribing as well

kockenque’s picture

subscribe

mehmeta’s picture

There you go folks. With the patch, the module treats the CCK imagefields just like any other file attachment. I was confused on how to get the content types to use this module, so added a quick pointer on admin settings as well. The patch is on top of the latest beta2 release. Enjoy!

mehmeta’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta2
Status: Closed (fixed) » Needs review
mehmeta’s picture

A small fix, please use this file instead.

Mark Theunissen’s picture

Status: Needs review » Needs work

mehmeta, thanks for the patch! There are a few issues with it though.

1) The form element $form['galleria_content_type'] does not use Drupal's t() or l() functions at all. However, in principle it's a good idea to put a message in there somehow. Maybe drupal_set_message() would be better?

2) Your approach is to add the images to node->files array. While this works and would probably be fine in 90% of the cases, it's a very hackish way to approach CCK. The correct way to implement this would be to write a CCK formatter for image fields (much the same way that lightbox does).

For those reasons I'm not going to commit this patch. You're welcome to resubmit. Check out the http://drupal.org/project/cck_formatters project for examples on how to work with formatters.

kirilius’s picture

I don't use Linux and can't use patches. How can I get a working Galleria patched so that it takes it's images from an imagefield?
How about a new release with the patched code? A branched release?

kirilius’s picture

Can anybody post the patched code for the template_preprocess_galleria function?

ChrisBryant’s picture

subscribing

kirilius’s picture

This module here might be the solution for this issue: http://drupal.org/project/views_galleria

Using views as a source for any presentation module (not just Galleria) is the way to go because of its flexibility.

maulwuff’s picture

Status: Needs work » Needs review
FileSize
3.64 KB

here is a patch to use imagefield, if present. you have to set the name of the field in the settings page

this is for 6.x-1.0-beta4

please review

maulwuff’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-beta4
Mark Theunissen’s picture

Status: Needs review » Needs work

Thanks for the patch. The problem is that it's still not the correct implementation (see my comments in #14 above).

The correct way to do this is by writing a CCK formatter (see the example projects http://drupal.org/project/cck_formatters).

maulwuff’s picture

ok, there are still some problems with my patch, like "empty fieldname will break your site" and "no caption for images are shown".
I'll have a look at the formatters. Do you have any experience with them?

Mark Theunissen’s picture

Yeah I do, but I don't have time to write the patch myself unfortunately.

maulwuff’s picture

can you give me a hint, what to do with the images in the formatter? as it gets called for every image in the imagefield, I can't build up a whole galleria. I think I have to pass them to somewhere else for the final theming

Mark Theunissen’s picture

The formatter function gets called once for the imagefield, passing in every image in that one field (it has to be a multi-field). At that point, you generate the HTML much the same way as the existing theme function does (it may just require refactoring the theme function).

maulwuff’s picture

Status: Needs work » Needs review
FileSize
7.56 KB
4.14 KB

here we go. imagefield themed by the formatter
please review.

in order to get it to work you have to go to content type -> manage field, set formatter to "Styled by Galleria".
see attached image

maulwuff’s picture

FileSize
15.78 KB

better image

Mark Theunissen’s picture

Nice work, I'll review next week, but it looks like you got the correct thing there (from the screenshot)!

Mark Theunissen’s picture

Could please re-roll the patch with the -up switch as per http://drupal.org/patch/create? Against the DRUPAL-6--1 branch, which has a number of small bugfixes of late...

Thanks!

Mark Theunissen’s picture

maulwuff’s picture

here we go. Patched against the 6 branch (hopefully)
I replaced the file extension thing by file_validate_extensions()

Mark Theunissen’s picture

1) We can't use file_validate_extensions() because it skips validation for user #1. Normally, a beginner who is using the Galleria module will be logged in as user #1 and thus will circumvent this check.

2) Your indentation and code formatting isn't consistant, you're using two spaces, one space, and tab characters. Sometimes even 4 spaces.

3) The comments are not in the correct format. They shouldn't be one space to the left, but start on the same column.

4) You've copy-pasted functions from the examples and left old comments that don't apply to the Galleria module. e.g. "Theme a textfield as a comma-separated list."

Please run your changes through the http://drupal.org/project/coder module on strictest mode, and then re-roll patch against DRUPAL-6--1 (which has had another commit as of writing this comment).

Sorry to be a pain. ;)

Mark Theunissen’s picture

Status: Needs review » Needs work
maulwuff’s picture

"pain" ... that's the word man. I rehacked the patch in a diff-tool while having "max payne" on my mind. You could have applied my patch before getting active again. There was no commit for 1 month.
Please fix these issues and commit. Sorry for the comments, though. I won't spend another evening on that.

roger6106’s picture

I am looking forward to this patch being moved into the project. It looks like this module will be exactly what I need once this is added. maulwuff, thanks for the work you have been doing on this patch.

Mark Theunissen’s picture

Ok I'll see if I can squeeze some time tomorrow..

eromba’s picture

Version: 6.x-1.0-beta4 » 6.x-1.x-dev
Status: Needs work » Needs review
FileSize
6.4 KB

Here's a re-roll of the patch from #31 against the latest dev version, and I believe I've covered everything that you pointed out in #32, Mark.

I've tested this with the Upload module and everything seems to be working as intended. However, I have NOT tested the patch whatsoever with CCK Imagefield, so my efforts may quickly prove to be made for naught. I did follow maulwuff's work closely, though, so I'm crossing my fingers!

Mark Theunissen’s picture

Thanks prof1337. The patch is great, but I fear that the logic is still wrong. All the code that was located in a theme function is now in a non-overrideable function called "_galleria_build". Anyone who has implemented a theme preprocess function will get a nasty surprise.

There is also no way to override the themeing of a galleria in one place for both the CCK field and the uploaded files. I.e. I can override the theme function for the CCK field, or for the upload files, but they have to be separate.

The correct approach is to have one theme function that returns a themed galleria that is called by both the CCK and the file upload sides.

I will see if I can sort this out today.

Mark Theunissen’s picture

Deleted - never mind

maulwuff’s picture

the upload module uses objects for the attachments, while imagefield uses arrays for the items.
originally I built up an array to pass it in to _galleria_build().
prof1337 switched it to object.

Mark Theunissen’s picture

Status: Needs review » Fixed

There are other considerations too - for example the lightbox link will only work with a Galleria created from attached files. For the moment, I think this is acceptable. I've commited the patch with quite a few changes (fixing the theme issue I mentioned above).

Please inspect the diff.

Thanks everyone! Let me know how your testing goes.

eromba’s picture

Looks good, Mark! Good decision regarding the theme functions.

The new dev version seems completely operational with uploads made via the Upload module.

frost’s picture

I've got Galleria working fine with attachments, but would prefer to use Image Fields if possible (mainly because I want to be able to use image_fupload for bulk uploading), so just tried to test the new support for CCK Image field, which is a great addition. However, I cannot get it working. May simply be a documentation/understanding issue? Anyway here's what I've done:

Created new content type with FileField and Image Widget. Content type set to use Galleria.
Created new node of the new content type, with a couple of images attached
Viewing the node just gives me the (expected) error message "Invalid Galleria: there are no attachments.", because the content type doesn't have any attachments. That tells me it is Galleria-enabled, but the images don't show up in a Galleria display so its just an ordinary display of the node.

I assume I've missed something; is there something else I need to do to get Galleria to recognise the Image Fields?

Thanks!

Versions:
Drupal 6.9
Galleria 6.x-1x-dev (29 April 09)
CCK 6.x-2.2
File Field 6.x-3.0
Image Field 6.x-3.0

frost’s picture

Sorry, my bad. I forgot to set the CCK formatter to display the new field as a Galleria for the new content type!

maulwuff’s picture

did you set the field formatter of the imagefield?
see #26 and #27

edit: you were first ;)

TheAlienShore’s picture

Awesome! I'm anxiously awaiting the next dev version with this patch included. Thanks!

Mark Theunissen’s picture

You can download and try the dev version! Test it out.

http://ftp.drupal.org/files/projects/galleria-6.x-1.x-dev.tar.gz

perandre’s picture

Works great! I had to turn the Galleria warning on and off (didn't work right away). If on, you still get a warning when using fields (not core upload). Thanks!

Mark Theunissen’s picture

You don't need to enable the Galleria under "Workflow settings" for a content type, if you are using the CCK implementation. I have updated the text on the form so it explains this.

TheAlienShore’s picture

FileSize
202.85 KB

I'm using Galleria successfully with ImageField. The only issue I'm still having is I've set a maximum of images to 10. If a user doesn't upload exactly 10, Galleria still tries to display 10 thumbnails and displays error messages in the remaining ones. Please see attached screenshot. Thanks.

Mark Theunissen’s picture

Assigned: Unassigned » Mark Theunissen
Status: Fixed » Active

Thanks for the bug report, I can imagine that it would do something like that ;)

Will try fix next week.

davidwhthomas’s picture

heh, perhaps I should have checked this issue queue first, I made a simple patch to use imagefield.

You can choose the imagefield to use and choose the mode - upload module or imagefield

more info:

http://drupal.org/node/465518

DT

Mark Theunissen’s picture

Thanks, but as you can see, the feature is already implemented!

Mark Theunissen’s picture

Status: Active » Fixed
FileSize
1.22 KB

Fixed in dev using attached patch.

TheAlienShore’s picture

Awesome! Thanks, Mark. It works perfectly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.