Hi,

There are some errors in the output generated by the gallery list page which will not validate and produces the report:

"document type does not allow element "div" here"

My output code is:

Clearly the issue is the 'div' block element contained within the inline 'a' element which is not allowed. Can this be changed please or have you any suggestions?

Thanks

Comments

joachim’s picture

It's caused by this in the image_gallery_handler_field_gallery_cover_thumbnail class:

  /**
   * Returns field html.
   */
  function render($values) {
    $nid = $this->get_cover_node_nid($values);

    $latest_node = node_load($nid);
    $output = image_display($latest_node, $this->options['image_derivative']);
    $output = $this->render_link($output, $values);
    // Wrap a common class so the thumbnail can be style no matter what field.
    // TODO: theme function?
    return '<div class="image-gallery-view-cover-thumbnail">' . $output . '</div>';
  }

What is happening is that we depend on Views to make the actual link. That means the A element goes around whatever we output in render() -- render_link() doesn't actually make the link there and then, it just raises a flag for it to happen later on in advanced_render().

I put the DIV in because I felt it was necessary to have a reliable way to grab that image thumbnail no matter what field it is -- so if you change the field to another of the gallery cover selection methods, you still have your styles.
However, given the amount of hoop-jumping that would be involved to get this in, I am inclined to simply remove that DIV. There is a class 'image-thumbnail' on the image, after all, and that can be selected within the term view.

Any objections to my removing it?

(PS. Good catch by the way!)

drunkencelt’s picture

Hi Joachim,

I see what you were trying to do which makes sense. I think the 'image-thumbnail' class will be enough though. More and more people are looking for validation with Drupal (as in my case) so I think I'd just take the 'div' out altogether.

Great module though. Simple to use for users which was my goal in choosing it.

Cheers

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Could you test this patch?

grn’s picture

Hmm, the patch will not fix my validation problem. I removed the <h3> tag from these files:

image/contrib/image_gallery/views/theme/image-gallery-view-image-gallery-terms.tpl.php
image/contrib/image_gallery/image_gallery.pages.inc
image/contrib/image_gallery/views/image_gallery.views_default.inc

And I validate perfectly! sample

joachim’s picture

Urgh, but I really want the H3 to be on terms, for backwards compatibility and for semantic HTML!

grn’s picture

Okay, you should have your H3 like this: <h3><a href="link">term</a></h3>

and not like this: <a href="link"><h3>term</h3></a>

joachim’s picture

...which we can't do because of reasons in #1 above.

I'll look into Semantic Views perhaps, see if bits of that can be applied.
Alternatively, we ditch the H3s completely and direct users to install Semantic Views themselves.

(Though: st00pid HTML: why can't a block element entirely be a link???)

grn’s picture

Sorry, didn't see that in #1

Alternatively, we ditch the H3s completely and direct users to install Semantic Views themselves.

Good idea.

I think valid (x)HTML is 1. priority.

joachim’s picture

Agreed.
But wait till all the themers start complaining about DIV soup though :/

grn’s picture

Hi.

I just upgraded to Image 6.x-1.0-beta5. Now my gallery overview does not validate. Validating manually.

How can I help with this?

joachim’s picture

I haven't got round to fixing this I'm afraid...

sp3boy’s picture

Before I make a patch, can I just check I've not missed anything obvious?

Is there any problem changing the div.image-gallery-view-cover-thumbnail to a span? Apart from requiring restyling by anybody who has styled div.image-gallery-view-cover-thumbnail of course.

As far as I know, although a span is notionally in-line, it can take any styling that a div can and the W3 validator was happy when I tried it with the span.

Just a thought.

joachim’s picture

Am I right in thinking it can't be a DIV because it's inside an A? (In which, frankly, HTML is being st00pid.)

Regarding the title, maybe if we make our own handler for the gallery title we can keep the H3. We'd need to implement our own advanced_render() and co.

grn’s picture

Good idea with the span.

sp3boy’s picture

StatusFileSize
new988 bytes

OK well here's a patch to change to a span.

Status: Needs review » Needs work

The last submitted patch, image-gallery-649384-15.patch, failed testing.

sp3boy’s picture

StatusFileSize
new972 bytes

Revised patch *sigh*

sp3boy’s picture

Status: Needs work » Needs review

Hmm... think I need to change the status? I'm not up to speed with this automated testing.

Status: Needs review » Needs work

The last submitted patch, image-gallery-649384-15-unix-format.patch, failed testing.

sp3boy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.01 KB

RTFM I suppose... new patch.

sp3boy’s picture

#20: image-gallery-649384-20.patch queued for re-testing.

joachim’s picture

Status: Needs review » Fixed

Committed the patch in #20:

#649384 by sp3boy: Fixed gallery thumbnail HTML to pass W3C validation.

Is this issue fixed now, or do other problems remain?

Status: Fixed » Closed (fixed)

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

joachim’s picture

Title: W3C Validation Error on Gallery Output » W3C validation error on gallery terms view thumbnails

Changing title to keep track of duplicates.