Creating new barebones plugin imgcache.

Eventually this will download and cache external images. Starting work on #27.
This commit is contained in:
Jason Williams 2021-01-02 15:06:56 -07:00
parent 2026e4a872
commit 0f302ec5ba
4 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,32 @@
<?php namespace JasonWilliams\ImgCache;
/**
* The plugin.php file (called the plugin initialization script) defines the plugin information class.
*/
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => 'Image Cache',
'description' => 'Saves external images locally and presents them via a twig filter.',
'author' => 'Jason Williams',
'icon' => 'oc-icon-cloud'
];
}
public function registerMarkupTags()
{
return [
'filters' => [
'imgcache' => function($imgurl) {
return $imgurl;
}
]
];
}
}

View File

@ -0,0 +1,6 @@
plugin:
name: 'Image Cache'
description: 'Saves external images locally and presents them via a twig filter.'
author: 'Jason Williams'
icon: oc-icon-cloud
homepage: 'https://ja.son-williams.ca/'

View File

@ -0,0 +1 @@
0.0.1: Initial version

View File

@ -13,7 +13,8 @@
<div class="{{ feeditemclass }}" data-timestamp="{{ post.timestamp }}">
<div class="card">
{% if post.extra.img %}
<img class="card-img-top" src="{{ post.extra.img }}">
<!-- <img class="card-img-top" src="{{ post.extra.img }}"> -->
<img class="card-img-top" src="{{ post.extra.img | imgcache }}">
{% elseif post.extra.lat %}
<img class="card-img-top" src="https://api.mapbox.com/styles/v1/jason32dev/ckgehopjc2o1y19o09aqs4x11/static/pin-l+B05C71({{ post.extra.lng }},{{ post.extra.lat }})/{{ post.extra.lng }},{{ post.extra.lat }},14,0/545x300@2x?access_token=pk.eyJ1IjoiamFzb24zMmRldiIsImEiOiJjazFsNHd5djcwMXptM2htbW8zM3MyZGxuIn0.-TtNNGFysQPQRfGR1P8DUA">
{% endif %}