In my opinion, line 203 in imceimage.module
( $id = !empty($id)? 'id="'. $id .'" ':'';)
should be
$id = !empty($id)? 'class="'. $id .'" ':'';
because otherwise, it won't be possible to create views that show nodes which all have an imceimage field from the same type - there would be the same "id" several times, which is senseless and invalid XHTML.

CommentFileSizeAuthor
#7 imceimage-318591-7.patch559 bytesdanepowell

Comments

yang_yi_cn’s picture

It's interesting. I recently got the co-maintain right of this project and would like to try this change. However, I'm not sure if it is the right way to do it yet.

Actually, all my imceimages now have id='imceimage-field_myfield_name-', which doesn't seem correct, but how to set the 'id' or 'class' attribute to test ?

danepowell’s picture

Subscribing... this is the only issue breaking XHTML validation on my site right now, so I'm quite interested to see what progress is made...

danepowell’s picture

Is there a reason why the img tag has to have an id attribute at all?

danepowell’s picture

Status: Needs review » Active
danepowell’s picture

Title: Error in imceimage.module causing invalid/senseless HTML » imceimage.module produces invalid HTML (non-unique id attributes)

This is actually a fairly big deal, because it crops up not just in Views containing image fields, but also on pages with multiple teasers containing image fields. I'm sure it is breaking validation on many people's sites. I am happy to work on a solution, but I'm not exactly sure what the best path forward is. The first idea off the top of my head is to remove the id attribute altogether, since I'm not sure it is used in its current form anyway. Does anyone know how other similar CCK modules solve this problem?

danepowell’s picture

Looking at similar modules, it does seem that the standard is to have only a class and no id attribute.

danepowell’s picture

Status: Active » Needs review
StatusFileSize
new559 bytes

Okay, well here is a patch against 6.x-1.0-beta2 that gets rid of the id attribute and thus produces valid XHTML. The id attribute seems completely unnecessary to me, especially since it's already broken to begin with.

danepowell’s picture

Or if you want to keep the id attributes in, I have just discovered form_clean_id, which should get the job done. Someone could easily implement that, but again I don't think it's necessary.

anotherdave’s picture

subscribing - again, only thing breaking validation on my site. (Personally, would never need the ID attribute.)

Before this thread was pointed out to me, I had logged this issue myself. Had mentioned there - would appending the NID to the outputted ID solve this issue? As in, at the moment the code generated is along the lines of:

imceimage- [field name] _image-[field number]

Why not:

imceimage- [field name] _image-[field number]_[nid]

Would give a completely unique ID attribute, but still leave the ID if people need it.

Dave

danepowell’s picture

That might be a good solution if we want to keep the ID around, but I still think form_option_id would be better in that case, since it's sole purpose is to generate unique IDs :)

Still- any solution to this is going to generate IDs that are inconstant, i.e. ones that are difficult to use with JS and probably impossible to style with CSS. Not only does this make me think that the ID attribute is inappropriately used here, but it negates much of the motivation for having it there at all. And I still haven't heard an argument for keeping it around. No other CCK fields that I have on my site use the ID attribute, and any sort of styling should be able to be done by referencing the wrapping class.

danepowell’s picture

Can anyone other than me and Dave (preferably a maintainer) weigh in on this? I think whatever fix we decide to go with should be fairly easy to implement. Let's just get it done already.

anotherdave’s picture

+1

It's a pity that such an easy thing to fix is breaking validation. Would there be any reasable objections to making this change?

danepowell’s picture

Status: Needs review » Reviewed & tested by the community

There seems to be good support for this, the patch is simple, let's just commit it.

Does this module even have an active maintainer any more?

FWIW, I've since dumped this module in favor of others which, by the way, do not use ID attributes.

panis’s picture

Assigned: Unassigned » panis
Status: Reviewed & tested by the community » Fixed

fixed in 6.x-1.x-dev

thanks for your help.
id replaced with class. The id was an early requirement from here see here #264274: Getting a CSS ID or Class for the IMCE CCK image

panis’s picture

Status: Fixed » Closed (fixed)