Skip to content

Commit

Permalink
Merge pull request #17 from codewithkyle/wip-2.2
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
codewithkyle authored Jul 7, 2022
2 parents 9a822a7 + 7e7af87 commit 7affe41
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 372 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

## [2.2.0] - 2022-07-07

### Added

- support for S3-compatible object storage solutions (like [Digital Ocean Spaces](https://www.digitalocean.com/products/spaces)) ([#16](https://github.com/codewithkyle/craft-jitter/issues/16))
- `craft.jitter.url(asset, params)` method

### Fixed

- improved image caching response times ([#15](https://github.com/codewithkyle/craft-jitter/issues/15))
- `craft.jitter.transformImage()` would cache transformed images using the assets `uid` instead of `id` ([#14](https://github.com/codewithkyle/craft-jitter/issues/14))

### Updated

- composer packages
- Jitter Core v1.1.0 -> v2.0.0

## [2.1.0] - 2022-05-31

### Added
Expand Down Expand Up @@ -113,7 +130,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- delete local files
- delete S3 files

[Unreleased]: https://github.com/codewithkyle/craft-jitter/compare/v2.1.0...HEAD
[Unreleased]: https://github.com/codewithkyle/craft-jitter/compare/v2.2.0...HEAD
[2.2.0]: https://github.com/codewithkyle/craft-jitter/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/codewithkyle/craft-jitter/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/codewithkyle/craft-jitter/compare/v1.2.6...v2.0.0
[1.2.6]: https://github.com/codewithkyle/craft-jitter/compare/v1.2.5...v1.2.6
Expand Down
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ To install the plugin, follow these instructions.

## Configuring Jitter

Jitter can be configured by adding a `jitter.php` file to your projects `config/` directory.
Jitter can be configured to use S3-compatible object storage solutions by adding a `jitter.php` file to your projects `config/` directory.

```php
<?php

return [
'accessKey' => getenv("S3_PUBLIC_KEY"),
'secretAccessKey' => getenv("S3_PRIVATE_KEY"),
'region' => 'us-east-2',
'bucket' => 'bucket-name',
'folder' => 'transformed-images',
"accessKey" => getenv("PUBLIC_KEY"),
"secretAccessKey" => getenv("PRIVATE_KEY"),
"region" => "region-name",
"bucket" => "bucket-name",
"folder" => "transformed-images",
"endpoint" => getenv("ENDPOINT_URL")
];
```

> **Note**: the `endpoint` config value is optional. You will only need to use it when using an S3-compatible alternative S3 cloud object storage solution (like Digital Ocean Spaces).
## Using Jitter

Requesting an image transformation through the API:
Expand All @@ -50,11 +53,12 @@ Requesting an image transformation through the API:
Requesting an image transformation via Twig:

```twig
{# This will transform the image on page load #}
{# This will transform the image when the template renders. #}
{# This can cause site-wide performance issues depending on how many times this method is used (per template) and how much RAM is available. #}
{% set transformedImageUrl = craft.jitter.transformImage(entry.image[0], { w: 150, ar: "1:1", m: "fit", fm: "gif", q: 10 }) %}
{# For a faster template render build the API URL instead #}
{% set transformedImageUrl = "/jitter/v1/transform&id=" ~ entry.image[0].id ~ "&w=150&ar=1:1&m=fit&fm=gif&q=10" %}
{% set transformedImageUrl = craft.jitter.url(entry.image[0], { w: 150, ar: "1:1", m: "fit", fm: "gif", q: 10 }) %}
<img
src="{{ transformedImageUrl }}"
Expand All @@ -72,8 +76,12 @@ Generating transformations via PHP:

```php
$jitter = new \codewithkyle\jitter\services\Transform();
$src = "/jitter/v1/transform?id=" . $image->id . "&w=300&ar=1:1";
$srcset = $jitter->generateSourceSet($image->id, [
$src = $jitter->generateURL([
"id" => $image->id,
"w" => 300,
"ar" => "1:1",
]);
$srcset = $jitter->generateSourceSet($image, [
[
"w" => 300,
"h" => 250,
Expand All @@ -94,7 +102,7 @@ Transformation parameters:
| Parameter | Default | Description | Valid options |
| ------------- | -------------------------- | ------------------------------- | ---------------------------------------------- |
| `id` | `null` | the image asset id | `int` |
| `path` | `null` | the image asset id | `int` |
| `path` | `null` | the image file path | `string` |
| `w` | base image width | desired image width | `int` |
| `h` | base image height | desired image height | `int` |
| `ar` | base image aspect ratio | desired aspect ratio | `int`:`int` |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "codewithkyle/jitter",
"description": "A just in time image transformation service.",
"type": "craft-plugin",
"version": "2.1.0",
"version": "2.2.0",
"keywords": [
"craft",
"cms",
Expand All @@ -25,7 +25,7 @@
"php": "^8.0",
"craftcms/cms": "^4.0",
"aws/aws-sdk-php": "^3.0.0",
"codewithkyle/jitter-core": "^1.1.0"
"codewithkyle/jitter-core": "^2.0.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 7affe41

Please sign in to comment.