Title: Returning empty src
Last modified: August 21, 2016

---

# Returning empty src

 *  Resolved [iangeek](https://wordpress.org/support/users/iangeek/)
 * (@iangeek)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/returning-empty-src/)
 * Odd one this…
 * I recently did a massive _migration_ from Typepad, all of which went without 
   hitch, using Image Teleporter to grab the images from Typekit’s ropey all-in-
   one giant image dumpster and move them into WP’s more ordered media library –
   adding the file extension along the way, since Typekit doesn’t seem to think 
   you need one. Nice one TK :/
 * Anyway, worked fine the first time, but since the project isn’t finished I’m 
   now doing a re-import to get the blogs in sync again, and this time things aren’t
   working so well. The batch feedback indicates that its processed the images, 
   but no sign of them in the media library, and the image src is being returned
   back empty on the post, so something is presumably erroring somewhere.
 * Any thoughts?
 * [https://wordpress.org/plugins/image-teleporter/](https://wordpress.org/plugins/image-teleporter/)

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

 *  Thread Starter [iangeek](https://wordpress.org/support/users/iangeek/)
 * (@iangeek)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726266)
 * Just FYI, trying the older “Linked IMGs to Gallery Attachments” and it seems 
   to be working fine. But I’d sooner use your version if possible, if only for 
   the batch option.
 * Ta!
 *  Plugin Contributor [Trisha Cupra](https://wordpress.org/support/users/trishacupra/)
 * (@trishacupra)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726446)
 * I’m sorry it didn’t work as you expected.
 * The plugin has some limitations. Things like spaces and symbols in the file name,
   and a lack of a file extension can all cause hiccups in the process.
 * Glad the older plugin worked for you.
 *  [amfriedman](https://wordpress.org/support/users/amfriedman/)
 * (@amfriedman)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726497)
 * Yeah, similar issue with the bulk importer, and I believe the one-off importer
   as well.
 * The plugin is choking on the presence of any space in the img src URL like below:
   
   [http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth](http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth)
   Magazine/2012 Summer/TravMed.ashx?h=375&w=300&as=1
 * When I correct the URLs before they go into the system, by replacing all spaces
   with %20 (like below), then the plugin still does not import properly — it actually
   wipes out the src attributes completely and the posts end up with dead img tags.
 * [http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth%20Magazine/2012%20Summer/TravMed.ashx?h=375&w=300&as=1](http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth%20Magazine/2012%20Summer/TravMed.ashx?h=375&w=300&as=1)
 * Any fix coming?
 *  [amfriedman](https://wordpress.org/support/users/amfriedman/)
 * (@amfriedman)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726498)
 * It also wipes out image src URLs that look like this:
 * [http://fairfoods.org/mar.php?u=aHR0cDovL3d3dy5jb21tb253ZWFsdGhtYWdhemluZS5vcmcvRGVwYXJ0bWVudHMvU3RhdGlzdGljYWxseS1TaWduaWZpY2FudC8yMDEyL1N1bW1lci9___2BL21lZGlhL0ltYWdlcy9Db21tb253ZWFsdGggTWFnYXppbmUvMjAxMiBTdW1tZXIvVHJhdk1lZC5hc2h4P2g9Mzc1JmFtcDt3PTMwMCZhbXA7YXM9MQ___3D___3D](http://fairfoods.org/mar.php?u=aHR0cDovL3d3dy5jb21tb253ZWFsdGhtYWdhemluZS5vcmcvRGVwYXJ0bWVudHMvU3RhdGlzdGljYWxseS1TaWduaWZpY2FudC8yMDEyL1N1bW1lci9___2BL21lZGlhL0ltYWdlcy9Db21tb253ZWFsdGggTWFnYXppbmUvMjAxMiBTdW1tZXIvVHJhdk1lZC5hc2h4P2g9Mzc1JmFtcDt3PTMwMCZhbXA7YXM9MQ___3D___3D)
 *  [amfriedman](https://wordpress.org/support/users/amfriedman/)
 * (@amfriedman)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726499)
 * OK, it is likely not the URL itself but the mime type or something associated
   with the headers served with the target image. media_handle_sideload() is throwing
   a security error.
 * I threw some debug code into the plugin here:
 *     ```
       function bml_it_sideload ($file, $url, $post_id) {
       	if(!empty($file)){
       		/// lots of code ///
   
       		$id = media_handle_sideload($file_array, $post_id, $desc);
       		$src = $id;
   
       		if(is_wp_error($id)) {
       		   #### THIS IS TRIGGERED ####
       			@unlink($file_array['tmp_name']);
       			return $id;
       		}
   
       	}
       	if (!empty($src)) return $src;
       	else return false;
       }
       ```
   
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been damaged by the forum’s parser.]_
 * I’m printing out $pathparts here:
    Array ( [dirname] => /tmp [basename] => TravMed4.
   tmp [extension] => tmp [filename] => TravMed4 )
 * Full URL:
    [http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth%20Magazine/2012%20Summer/TravMed.ashx](http://www.commonwealthmagazine.org/Departments/Statistically-Significant/2012/Summer/~/media/Images/Commonwealth%20Magazine/2012%20Summer/TravMed.ashx)
 * and the wp_error (which is NOT displaying to the WP admin UI): Sorry, this file
   type is not permitted for security reasons.
 *  [Neelixx](https://wordpress.org/support/users/neelixx/)
 * (@neelixx)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726504)
 * I think this may be the exact error I may be running into. I haven’t checked 
   the MIME type, but when I browse to the URL in SRC, it downloads the image, rather
   than displays it.
 * This may be why my SRC is empty also. Even though, it displays fine.
 * Can we get some code in there, that if it doesn’t match the MIME type, to leave
   the URL alone, rather than strip it out?
 * Either that, or display an error (or log) on problems?

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

The topic ‘Returning empty src’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/image-teleporter_6d7d6f.svg)
 * [Image Teleporter](https://wordpress.org/plugins/image-teleporter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/image-teleporter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/image-teleporter/)
 * [Active Topics](https://wordpress.org/support/plugin/image-teleporter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/image-teleporter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/image-teleporter/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Neelixx](https://wordpress.org/support/users/neelixx/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/returning-empty-src/#post-4726504)
 * Status: resolved