Can the thumb function be modified to use the ImageOptim API ?
It would be ideal to only have to set c::set('imageOptim.username', 'abcdef123566');
in the config.php and then the thumbnails aren’t generated on the own server anymore but over the ImageOptim API .
texnixe
December 28, 2016, 11:04pm
2
You can probably just use a function that returns the required URL, in the same way Kirby used imgix to generate thumbnails on the fly:
<?php
function imgix($url, $params = array()) {
if(is_object($url)) {
$url = $url->url();
}
$url = trim(str_replace(array(url(), 'https://assets.getkirby.com/'), '', $url), '/');
$url = 'https://getkirby.imgix.net/' . $url . '?' . http_build_query($params);
return $url;
}
<?php snippet('header') ?>
<main class="main" role="main">
<h1 class="alpha margin-bottom">Made with Kirby and <b class="red">♥</b class="love"></h1>
<ul class="reference-list list-3">
<?php $references = $page->children()->visible()->flip()->paginate(30) ?>
<?php foreach($references as $reference): ?><!--
--><li class="screenshot">
<div class="screen-wrap">
<?php if($reference->hasImages()): ?>
<img src="<?php echo imgix($reference->image(), array('w' => 350, 'h' => 220, 'fit' => 'crop')) ?>" alt="Screenshot: <?php echo $reference->title() ?>">
<?php endif ?>
<div class="screen-refl"><a class="btn-white" href="<?php echo $reference->link() ?>">visit</a></div>
</div>
<a href="<?php echo $reference->link() ?>">
<h2 class="gamma truncate"><?php echo html($reference->title()) ?></h2>
<p><?php echo url::short($reference->link()) ?></p>
</a>
This file has been truncated. show original
Yes, that would be an option for the “on the fly” method. I would however
like to overwrite the thumb function if that is possible to actually store
the image on my own server
texnixe
December 29, 2016, 12:22pm
4
That is exactly what I was looking for, thank you @texnixe !