image_gallery doesn't work well with pathauto.

First problem is that pathauto doesn't seem to be able to figure out the image gallery an image node is associated with. I would expect a pathauto description like "photos/[catpath]/[title]" to create a URL alias like "photos/image_gallery_name/img_1234.jpg", but instead it just gives "/photos/img_1234.jpg".

Second problem is creating aliases for the image galleries themselves. Since they are taxonomy terms, pathauto can create aliases for them, but the alias points to "taxonomy/term/x" instead of "image/tid/x". So, the alias doesn't display the image gallery but just a list of the image nodes.

CommentFileSizeAuthor
#8 pathauto_node_gallery.patch1.35 KBellanylea

Comments

deciphered’s picture

Priority: Normal » Critical

I second this, this is a major issue for a page I'm currently working on as if my client adds or edits an Image Gallery it breaks the URL and the site.

deciphered’s picture

Category: feature » bug

Changed from Feature to Bug.

greggles’s picture

Category: bug » feature
Priority: Critical » Normal

I just wanted to point to http://drupal.org/node/23829 as a partial motivation for why this is in image_gallery and not in pathauto's issue queue.

I also wanted to change this to feature (because it is one - lacking an aliased URL for a portion of a site doesn't "break" the site) and set the priority to "normal" because it is. If anyone really wants to see this get done and feels this is critical then I suggest you put a bounty on it.

drewish’s picture

marked http://drupal.org/node/23830 as a duplicate (even though it predates this)

ellanylea’s picture

Beginning of a solution... create a new path pattern [imagepath]

1. I created galleries 'image/tid/3' and manually set their URL aliases to something like 'travel/zimbabwe/victoria_falls'.

2. Then I hacked pathauto_node.inc (I know I shouldn't, but this is experimental).

Added these lines to function node_pathauto($op):

      if (module_exists('image')) {
        $settings["placeholders"][t('[imagepath]')] =
          t('For image nodes, the aliased path of its gallery.');
      }

Added these lines to function node_get_placeholders($node):

  if (module_exists('image') and $node->type == 'image') {
		$tid = reset(array_keys(taxonomy_node_get_terms_by_vocabulary($node->nid, 3)));
		$gallery = taxonomy_get_term($tid);
		$imagepath .= drupal_get_path_alias(taxonomy_term_path($gallery));
    $placeholders[t('[imagepath]')] = $imagepath;
  } 
  else {
    $placeholders[t('[imagepath]')] = '';
  }

3. In pathauto, I set Pattern for all Image paths to: [imagepath]/[title]

Conclusion: all the image nodes 'node/23' are now 'travel/zimbabwe/victoria_falls/fly_high'

As always, feedback welcome :)

greggles’s picture

This generally looks great, but...

1) Pathauto provides an API. It's up to other modules to implement that in their own files.
2) Can you provide these as a patch? http://drupal.org/patch
3) Shouldn't the module_exists check look for image_gallery?

ellanylea’s picture

1) Thx for the recommendation. I still wonder, since both pathauto and image are contributed modules, does it matter which module is modified to suit the other? Does this mean the image module does not provide an API?

2) I've been trying to create a patch, but ending up with a file that looks like:

- (every single line from pathauto_node.inc)
- (every single line from pathauto_node.inc)
- (every single line from pathauto_node.inc)
...
+ (every single line from pathauto_node_new.inc)
+ (every single line from pathauto_node_new.inc)
+ (every single line from pathauto_node_new.inc)
...

... which defies the whole point of creating a patch. I'm using WinXP and cygwin. What am I missing?

3) You're absolutely right, module_exists should check for image_gallery (not image)

ellanylea’s picture

StatusFileSize
new1.35 KB

lol, moments after I submitted the above reply, the patch generated correctly. I didn't change a thing... Gotta love Murphy. Anyhow, patch is now attached.

drewish’s picture

Status: Active » Needs work

it's probably a problem with line endings, use dos2unix and unix2dos to convert back and forth (sometimes they're called u2d and d2u).

i think the correct way to do this is to offer it up to the token module. recent versions of pathauto use token to gather up all the little bits.

rogerpfaff’s picture

is there a patch for 4.7.x too?

underpressure’s picture

I don't mean to complicate this and I know this should be added down the line but maybe while writing for this new feature you could take the following two ideas into consideration.

I'd like to see the follow two automated path ideas implimented for those of that have lots of images.

with image path enabled I'd like to see a setting for:

1. If no path is entered use term TITLE as path.

2. If no path is entered for photo use thumbnail title.

drewish’s picture

underpressure, i think what you're really asking for is token support. you should create a new feature request for that and make note of what data you think should be provided as tokens.

guillaumeduveau’s picture

First problem is that pathauto doesn't seem to be able to figure out the image gallery an image node is associated with. I would expect a pathauto description like "photos/[catpath]/[title]" to create a URL alias like "photos/image_gallery_name/img_1234.jpg", but instead it just gives "/photos/img_1234.jpg".

This now works very nice in 5.x-16 and possibly before, 5.x-1-dev and 5.x-2-dev, if you put photos/[catpath]/[title] in pathauto pattern for image node type your image nodes will be at this URL and also the image_gallery will print these URLs for the links to the image nodes. Of course you can do whatever you want with the pathauto pattern, this is just an example. Maybe you should try [catpath-raw] because pathauto wants -raw.

It works so image deals correctly with pathauto and token.

Second problem is creating aliases for the image galleries themselves. Since they are taxonomy terms, pathauto can create aliases for them, but the alias points to "taxonomy/term/x" instead of "image/tid/x". So, the alias doesn't display the image gallery but just a list of the image nodes.

OK this doesn't work yet.

It doesn't work so image_gallery doesn't deal correctly with pathauto and token.

I don't have the skills yet to fix this. All I know is that the problem is in image_gallery and not in image. Here's a feature request for token (or pathauto) support in image_gallery that I filled.

sun’s picture

Status: Needs work » Closed (won't fix)

Sorry, 5.x-1.x won't see any new features. Feel free to re-open this issue if it still applies to 6.x.