• Resolved Marc Nilius

    (@zottto)


    Hi!

    If I try to add an attachment (PDF file), the following JS error happens:

    Uncaught TypeError: Cannot read properties of undefined (reading ‘thumbnail’)
    in scripts.js line 27:

    if (attachment[i].sizes.thumbnail !== undefined ) url_image=attachment[i].sizes.thumbnail.url;

    The reason is, that the attachment object does not contain a property “sizes”, perhaps because it is a PDF file without preview image.
    But it has a “icon” property with the value of “/wp-includes/images/media/document.png”. Perhaps as a fallback, that should be used.

    Could you please fix this?

    Thanks,
    Marc

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author kgmservizi

    (@kgmservizi)

    Hi @zottto

    I can’t reproduce this error. Do you use latest plugin version and Gravity version?

    You can make me a video?

    Thanks

    Thread Starter Marc Nilius

    (@zottto)

    Hi @kgmservizi

    where can I send the video to? (I don’t want to publish it in a public forum)

    We are using latest version of GF and your plugin.

    Marc

    Plugin Author kgmservizi

    (@kgmservizi)

    Hi @zottto try latest version. Thanks (and thanks for another user that report ?? )

    Regards

    Thread Starter Marc Nilius

    (@zottto)

    Hi @kgmservizi,

    thanks for the update! It now mostly works as expected. ??

    When adding the PDF from the media library, there is no JS error anymore, but still a broken image (img tag has src attribute with the URL of the PDF file). After saving, the correct file icon is shown (instead of the non-existing thumbnail).
    Would be cool, if the next version could also show the correct icon image after adding the file (and already before saving the settings).

    To get the script correctly working, I needed to change the ‘version’ in gf-kgm-notification-attachment.php line 28 manually from ‘1.0’ to ‘1.1’ to avoid caching of the old script file. Perhaps this is something you could also improve in the next version to always use the “official” version number of the plugin there.

    Thanks for your help!

    Regards,
    Marc

    Plugin Author kgmservizi

    (@kgmservizi)

    Hi, you can try latest release? Thanks for report.

    Regards

    Thread Starter Marc Nilius

    (@zottto)

    Works perfectly for me now. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘JS error on adding PDF file’ is closed to new replies.