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!
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.
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 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
Any fix coming?
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
and the wp_error (which is NOT displaying to the WP admin UI): Sorry, this file type is not permitted for security reasons.
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?