Title: JavaScript error when searching for images
Last modified: August 9, 2017

---

# JavaScript error when searching for images

 *  [Milan Petrovic](https://wordpress.org/support/users/gdragon/)
 * (@gdragon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/)
 * Whenever I try to search for images, Google Chrome console logs this error:
 *     ```
       Uncaught TypeError: Cannot read property 'small' of undefined
           at Object.unsplash.displayImages (unsplash.js:112)
           at Object.success (unsplash.js:68)
           at i (load-scripts.php:2)
           at Object.fireWith [as resolveWith] (load-scripts.php:2)
           at y (load-scripts.php:4)
           at XMLHttpRequest.c (load-scripts.php:4)
       ```
   
 * And the search never finishes.
 * Milan

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/#post-9394635)
 * Hi [@gdragon](https://wordpress.org/support/users/gdragon/),
    I’m not able to
   recreate this issue in 3 unique environments… Maybe something was up with the
   Unsplash API at the time?
 *  Thread Starter [Milan Petrovic](https://wordpress.org/support/users/gdragon/)
 * (@gdragon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/#post-9394651)
 * When I click on Search (with no keyword), I get the results (latest of features
   images or something). And, if I click on the example search (coffee + woman),
   it also works. But, if I enter keyword: ‘chart’, I get the error.
 * I have inspected AJAX results returned from Unspash, and for the ‘chart’ I see
   3 results, so most likely problem is that your code fails to properly parse the
   results, and it assumes that some element is present, even if it is not (property‘
   small’).
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/#post-9394720)
 * Maybe it could have better validation, but even with that said searching for 
   chart doesn’t produce any errors for me.
 *  Thread Starter [Milan Petrovic](https://wordpress.org/support/users/gdragon/)
 * (@gdragon)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/#post-9394754)
 * I tried several times, all the same. All searches return the error, except the‘
   coffee + woman’. But, results are always returned from Unsplash, and all results
   have ‘urls’ ‘small’ property. I did some debugging, and in some cases (on line
   108 in unspash.js), photos array contains photos and one extra element as a function.
   Where that comes from, I have not gone too deep to find out. But, you just need
   to check if the element of photos is actually a photo element (object with urls
   propery), and it would be OK.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘JavaScript error when searching for images’ is closed to new replies.

 * ![](https://ps.w.org/instant-images/assets/icon-256x256.png?rev=2504172)
 * [Instant Images - One-click Image Uploads from Unsplash, Openverse, Pixabay, Pexels, and Giphy](https://wordpress.org/plugins/instant-images/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/instant-images/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/instant-images/)
 * [Active Topics](https://wordpress.org/support/plugin/instant-images/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/instant-images/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/instant-images/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Milan Petrovic](https://wordpress.org/support/users/gdragon/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-when-searching-for-images/#post-9394754)
 * Status: not resolved