I ran into a few issues with the way you name your cached image names I have a small patch that I made to resolve them and a suggestion on how better to name the file.
First the patch. I found that if the image caption had multiple periods in a row or the '+' symbol that the wordpress media library would be unable to resolve the file, the file is clearly there wordpress just refuses to see it. (As an aside, I'm a bit of a wordpress newbie and haven't mastered the frameword yes, so there are probably multiple ways to resolve this) To resolve this I made the following patch to instagrate-pro.php around line 2615:
$file_name = ($post_name == '') ? $file : $post_name; $file_name = sanitize_file_name($file_name); $file_name = remove_accents($file_name); $file_name = substr($file_name, 0, 100); /* WORKAROUND PATCH, NOTE FOR FUTURE MERGES .. */ $file_name = preg_replace('/\.+/','.',$file_name); $file_name = preg_replace('/\+/','',$file_name); /* END PATCH */ $file_name = $file_name .'.'. $info['extension'];
That said wouldn't it be better to use the instagram post id as the filename, it's (assumably) guaranteed unique and you could cut out your uniqueness checking.