• Hey all,
    I’ve just noticed that if an image is used several times, e.g shown in multiple posts on the same “page”, the img id tag makes the xhtml invalid. This because one element (the image) is shown multiple times, but has id associated with it.

    Anybody having the same experience? Any advice as to how to get around the issue?

    Kind regards,
    Hans Magnus

Viewing 8 replies - 1 through 8 (of 8 total)
  • I wont go into details.

    But if you use and element only once you use an ID.
    If you use it multiple times you use classes or CLASS.

    Of course!

    WP does this by it self, assuming the image only will be used once pr page. So when parsing the xhtml, WP assigns e.g. <img id="image67"... which is the attachment id of the uploaded file. So there is little the user can do about this.

    I can’t expect my users to actually go into code view to delete the id tag from the image.

    So, again, any ideas?

    – HM

    Hans,

    Can you provide a URL where this is happening?

    In my installs I’m not able to replicate what you’re describing. Images typically only display with an alt attribute but that’s it.

    I actually changed the post pr page to 5, so that the same image is not shown twice at the moment. But here is the url:

    http://www.mutator.no/

    If you check the source for images, they are appear e.g as:
    <img align="left" alt="2rhozetweb.gif" id="image76" title="2rhozetweb.gif" src="http://www.mutator.no/wp-content/uploads/2007/04/2rhozetweb.gif" />

    Should the id of the image be parsed?

    – HM

    Strange… I could reproduce it but only on a WP 2.0.11 install. There is no image id on my local or online 2.3.2 test install.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    If you’re using the default uploader with WordPress 2.3.2, then it does not insert an ID. The relevant code is in wp-admin/js/upload.js and looks like this:

    h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />";

    Basically it has a src and an alt but that’s it.

    Hans – if this error is continuing try something for me.

    Go to the Uploads panel of your WordPress administration and select one of your more recent images. Click on the Image and then click on “Links.” You should see a list of three possibilities. The first is just a url for the image while the other two show potential HTML code for displaying an image.

    In either of the second two dialogues are you seeing the id=”” included?

    Hey, thank you all for the effort, I see that the the posts containing imgid are posted with an older version of WP. However, the id doesn’t show up in the attachment managing links lists.

    So I guess I’ll go through the source to remove the ids from the older content.

    Thanks again,
    – HM

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘img id breaks XHTML’ is closed to new replies.