Problem/Motivation

My custom module implement theme_registry_alter to override the theme_file_link function in order to remove the icon and span wrapper around a file link. The introduces an error in wysiwyg-filter.js line 146:
TypeError: element[0] is undefined

This error is introduced by the assumption in the previous lines that <a> are only wrapped around images:

      // Parse out link wrappers. They will be re-applied when the image is
      // rendered on the front-end.
      if (element.is('a')) {
        element = element.children();
      }

Proposed resolution

Add a sanity check to the assumption every <a> links to an image.

Remaining tasks

  1. Write a patch
  2. Review

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#3 media_insert-sanity-check-2684853-3.patch898 bytesidebr

Comments

idebr created an issue. See original summary.

idebr’s picture

Issue summary: View changes
idebr’s picture

Status: Active » Needs review
StatusFileSize
new898 bytes

Attached patch implements the sanity check.

eelkeblok’s picture

Status: Needs review » Reviewed & tested by the community

This looks fine to me. RTBC.

  • joseph.olstad committed f353696 on 7.x-2.x authored by idebr
    Issue #2684853 by idebr, eelkeblok: Media wysiwyg insert assumes all...
joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

committed to dev branch 7.x-2.x dev
Thanks,

Status: Fixed » Closed (fixed)

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