Title: JS error on adding PDF file
Last modified: November 26, 2021

---

# JS error on adding PDF file

 *  Resolved [Marc Nilius](https://wordpress.org/support/users/zottto/)
 * (@zottto)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/)
 * 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](https://wordpress.org/support/users/kgmservizi/)
 * (@kgmservizi)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15108490)
 * Hi [@zottto](https://wordpress.org/support/users/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](https://wordpress.org/support/users/zottto/)
 * (@zottto)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15112806)
 * Hi [@kgmservizi](https://wordpress.org/support/users/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](https://wordpress.org/support/users/kgmservizi/)
 * (@kgmservizi)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15132322)
 * Hi [@zottto](https://wordpress.org/support/users/zottto/) try latest version.
   Thanks (and thanks for another user that report 🙂 )
 * Regards
 *  Thread Starter [Marc Nilius](https://wordpress.org/support/users/zottto/)
 * (@zottto)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15135801)
 * Hi [@kgmservizi](https://wordpress.org/support/users/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](https://wordpress.org/support/users/kgmservizi/)
 * (@kgmservizi)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15144198)
 * Hi, you can try latest release? Thanks for report.
 * Regards
 *  Thread Starter [Marc Nilius](https://wordpress.org/support/users/zottto/)
 * (@zottto)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15148009)
 * 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.

 * ![](https://ps.w.org/notification-attachments-for-gravity-forms/assets/icon-256x256.
   png?rev=2437346)
 * [Notification Attachments for Gravity Forms](https://wordpress.org/plugins/notification-attachments-for-gravity-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/notification-attachments-for-gravity-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/notification-attachments-for-gravity-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/notification-attachments-for-gravity-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/notification-attachments-for-gravity-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/notification-attachments-for-gravity-forms/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Marc Nilius](https://wordpress.org/support/users/zottto/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/js-error-on-adding-pdf-file/#post-15148009)
 * Status: resolved