Support » Plugin: AutoNav Graphical Navigation and Gallery Plugin » [Plugin: AutoNav Graphical Navigation and Gallery Plugin] IMG tag invalid at W3C (doesn't self-

  • Resolved LauraLW

    (@lauralw)


    Disclaimer: I’m a pretty new to PHP. Getting the following error at W3C:

    Line 43, Column 358: end tag for “img” omitted, but OMITTAG NO was specified
    …height=”120″ class=”autonav-image”></span><p class=”autonav-text”><a href=…

    You may have neglected to close an element, or perhaps you meant to “self-close” an element, that is, ending it with “/>” instead of “>”.

    I’m guessing it’s the following (from autonav/autonav-wl.php) that create those tags?

    /* *** HTML helpers *** */
    
    function an_create_tag ($html_tag, $html_attr) {
      $attrs = array($html_tag);
      if (is_array($html_attr)) {
        foreach ($html_attr as $attr => $value) {
          $attrs[] = $attr . '="' . esc_attr($value) . '"';
        }
      }
      return '<' . implode(' ',$attrs) . '>';
    }
    /* ********************** */
    
    function prepare_picture (&$pic) {  /* (! modifies $pic !) */
      $alt_text = strlen($pic['alt_text']) ? $pic['alt_text'] : $pic['title'];
      if (strlen($pic['error'])) {
        $error_print = $pic['pic_full_url'];
      } else {
        if (strlen($pic['image_url'])) {
          $pic['content'] =
    	an_create_tag('img', array('src' => $pic['image_url'], 'alt' => $alt_text,
    				   'width' => $pic['width'], 'height' => $pic['height'],
    				   'class' => $pic['class']));
        } else {
          $pic['error'] = 'Missing image';
          $error_print = apply_filters('autonav_missing_image',__($pic['error']), $pic);
          if (is_object($pic['page'])) {
    	$pic['error'] .= __(' for postid=').$pic['page']->ID;
          }
        }
      }
      if (strlen($pic['error'])) {
        $pic['content'] = an_create_tag('span', array('class' => implode(' ',array('autonav-error', $pic['class'])))) .
          "<!-- {$pic['error']} -->{$error_print}</span>\n";
      }
      if ($pic['permalink'] == '') {
        switch ($pic['linkto']) {
        case 'pic':
          $pic['permalink'] = $pic['pic_full_url']; // link to fullsize image
          break;
        case 'attpage':
          $pic['permalink'] = $pic['attpage'];
          break;
        }
      }
    }

    Could someone tell me how to make only the IMG tags self-close? Thanks!

    http://wordpress.org/extend/plugins/autonav/

Viewing 1 replies (of 1 total)
  • Plugin Author wlindley

    (@wlindley)

    Self-closing tags are XHTML, not HTML 4, and not exactly HTML 5 either. You do not need to say <img /> — just <img> is enough for proper HTML 4 and HTML 5. If you insist on having <img /> then you could modify an_create_tag, but you would need a list of tags that require self-closing… unnecessary complexity especially as it will be obsolete with HTML 5.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: AutoNav Graphical Navigation and Gallery Plugin] IMG tag invalid at W3C (doesn't self-’ is closed to new replies.