forked from friendica/friendica-addons
Compare commits
5 commits
5b88c3a879
...
12a9e9472f
Author | SHA1 | Date | |
---|---|---|---|
|
12a9e9472f | ||
|
7224eac3a3 | ||
|
58dc1ecef1 | ||
|
941818ffb8 | ||
|
5ea8dca4c4 |
3 changed files with 18 additions and 4 deletions
|
@ -239,6 +239,11 @@ function mailstream_do_images(array &$item, array &$attachments)
|
|||
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
|
||||
try {
|
||||
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
Logger::debug('mailstream: fetch image url failed', [
|
||||
'url' => $url, 'item_id' => $item['id'], 'return_code' => $curlResult->getReturnCode()]);
|
||||
continue;
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Logger::error('mailstream_do_images exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
|
||||
continue;
|
||||
|
|
|
@ -660,10 +660,14 @@ function retriever_extract(DOMDocument $doc, array $retriever) {
|
|||
* @return DOMDocument New DOM document with global URLs
|
||||
*/
|
||||
function retriever_globalise_urls(DOMDocument $doc, array $resource) {
|
||||
$components = parse_url($resource['redirect-url']);
|
||||
if (!array_key_exists('scheme', $components) || !array_key_exists('host', $components) || !array_key_exists('path', $components)) {
|
||||
$url = $resource['redirect-url'];
|
||||
if ($url == "") {
|
||||
$url = $resource['url'];
|
||||
}
|
||||
$components = parse_url($url);
|
||||
if (!array_key_exists('scheme', $components) || !array_key_exists('host', $components) || !array_key_exists('path', $components)) {
|
||||
return $doc;
|
||||
}
|
||||
}
|
||||
$rooturl = $components['scheme'] . "://" . $components['host'];
|
||||
$dirurl = $rooturl . dirname($components['path']) . "/";
|
||||
$params = array('$dirurl' => $dirurl, '$rooturl' => $rooturl);
|
||||
|
@ -829,7 +833,7 @@ function retriever_transform_images(array &$item, array $resource) {
|
|||
Logger::error('retriever_transform_images: unable to store photo ' . $resource['url'] . ' error: ' . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
$new_url = DI::baseUrl() . '/photo/' . $rid . '-0.' . $image->getExt();
|
||||
$new_url = DI::baseUrl() . '/photo/' . $rid . '-0' . $image->getExt();
|
||||
if (!strlen($new_url)) {
|
||||
Logger::warning('retriever_transform_images: no replacement URL for image ' . $resource['url']);
|
||||
return;
|
||||
|
|
|
@ -22,5 +22,10 @@
|
|||
<xsl:value-of select="concat('{{$rooturl}}',.)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="*/@src[not(contains(.,':'))]">
|
||||
<xsl:attribute name="src">
|
||||
<xsl:value-of select="concat('{{$dirurl}}',.)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue