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-');
|
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
|
||||||
try {
|
try {
|
||||||
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
|
$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) {
|
} catch (InvalidArgumentException $e) {
|
||||||
Logger::error('mailstream_do_images exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
|
Logger::error('mailstream_do_images exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -660,10 +660,14 @@ function retriever_extract(DOMDocument $doc, array $retriever) {
|
||||||
* @return DOMDocument New DOM document with global URLs
|
* @return DOMDocument New DOM document with global URLs
|
||||||
*/
|
*/
|
||||||
function retriever_globalise_urls(DOMDocument $doc, array $resource) {
|
function retriever_globalise_urls(DOMDocument $doc, array $resource) {
|
||||||
$components = parse_url($resource['redirect-url']);
|
$url = $resource['redirect-url'];
|
||||||
if (!array_key_exists('scheme', $components) || !array_key_exists('host', $components) || !array_key_exists('path', $components)) {
|
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;
|
return $doc;
|
||||||
}
|
}
|
||||||
$rooturl = $components['scheme'] . "://" . $components['host'];
|
$rooturl = $components['scheme'] . "://" . $components['host'];
|
||||||
$dirurl = $rooturl . dirname($components['path']) . "/";
|
$dirurl = $rooturl . dirname($components['path']) . "/";
|
||||||
$params = array('$dirurl' => $dirurl, '$rooturl' => $rooturl);
|
$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());
|
Logger::error('retriever_transform_images: unable to store photo ' . $resource['url'] . ' error: ' . $e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$new_url = DI::baseUrl() . '/photo/' . $rid . '-0.' . $image->getExt();
|
$new_url = DI::baseUrl() . '/photo/' . $rid . '-0' . $image->getExt();
|
||||||
if (!strlen($new_url)) {
|
if (!strlen($new_url)) {
|
||||||
Logger::warning('retriever_transform_images: no replacement URL for image ' . $resource['url']);
|
Logger::warning('retriever_transform_images: no replacement URL for image ' . $resource['url']);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -22,5 +22,10 @@
|
||||||
<xsl:value-of select="concat('{{$rooturl}}',.)"/>
|
<xsl:value-of select="concat('{{$rooturl}}',.)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
<xsl:template match="*/@src[not(contains(.,':'))]">
|
||||||
|
<xsl:attribute name="src">
|
||||||
|
<xsl:value-of select="concat('{{$dirurl}}',.)"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue