caique2001
Forum Replies Created
-
Forum: Plugins
In reply to: [RSS Post Importer] broken links to images in 2.0.2Fix:
1) in class-rss-pi-engine.php directly after $post = array …
$content = $post["post_content"]; // catch base url if (preg_match('/src="\//i', $content)) { preg_match('/href="(.+?)"/i', $content, $matches); $baseref = (is_array($matches) && !empty($matches)) ? $matches[1] : ''; if (!empty($baseref)) { $bc = parse_url($baseref); $scheme = (empty($bc["scheme"])) ? "http" : $bc["scheme"]; $port = $bc["port"]; $host = $bc["host"]; if (!empty($host)) { $preurl = $scheme . ":" . $port . "//" . $host; $post["post_content"] = preg_replace('/(src="\/)/i', 'src="' . $preurl . "/", $content); }; }; };2. in class-rss-pi-featured-image.php after $content =
// catch base url preg_match('/href="(.+?)"/i', $content, $matches); $baseref = (is_array($matches) && !empty($matches)) ? $matches[1] : ''; // get the first image from content preg_match('/<img.+?src="(.+?)"[^}]+>/i', $content, $matches); $img_url = (is_array($matches) && !empty($matches)) ? $matches[1] : ''; if (empty($img_url)) { return false; } $img_host = parse_url($img_url, PHP_URL_HOST); if (empty($img_host)) { if (empty($baseref)) { return false; }; $bc = parse_url($baseref); $scheme = (empty($bc["scheme"])) ? "http" : $bc["scheme"]; $port = $bc["port"]; $host = $bc["host"]; if (empty($host)) { return false; }; $img_url = $scheme . ":" . $port . "//" . $host . $img_url; }Forum: Plugins
In reply to: [RSS Post Importer] broken links to images in 2.0.2It’s their feed structure:
<description><![CDATA[<a href="http://www.taz.de/Kommentar-zum-Pariser-Anschlag/!152504/"><img align="left" style="margin-right:5px;" src="/uploads/images/152x76/AttentatParisKerze080115.jpg" border="0" width="152" height="76" /></a>Die Verteidigung der Liberalität muss die Antwort auf den Terror sein. Doch die französische Demokratie steht vor einer harten Probe. <a href="http://www.taz.de/Kommentar-zum-Pariser-Anschlag/!152504/">mehr...</a>]]></description>Omitting the base url seems fine in RSS (no issues in browser), but not in plain html. It needs some code to 1. detect there is no domain name in the img src, then to extract it from the first href and eventually to prefix img src.
Cheers, André
Forum: Plugins
In reply to: [RSS Post Importer] broken links to images in 2.0.2somehow the base url (http://www.taz.de/) gets lost in $content…
Forum: Plugins
In reply to: [RSS Post Importer] broken links to images in 2.0.2The given path is from the rss-feed site.
The img source on that specific site is _relative_ which is not handled correctly in the code.
E.g.: /uploads/images/152×76/fdpstuttgart06012014_dpa.jpg
is actually
http://www.taz.de/uploads/images/152×76/fdpstuttgart06012014_dpa.jpg
Hence, the link eventually is broken and nothing is uploaded.