Skip to content

Commit

Permalink
Built release for 0.4.6. For a full change log look at the notes with…
Browse files Browse the repository at this point in the history
…in the original/0.4.6 release.
  • Loading branch information
github-actions[bot] committed Mar 29, 2023
1 parent e95fe0d commit d31d53f
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 11 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
Changelog
=========

## v0.3.13
## v0.4.3

- Bug: Check model has mime type before chaking value
- Bug: Check model has mime type before checking value

## v0.3.12
## v0.4.2

- Bug: Don't trigger edit modal for non image files

## v0.4.1

- Bug: Fix WebP support for cropping and display

## v0.4.0

- Enhancement: Add filter to skip attachments during Smart Media processing

## v0.3.11

- Bug: AMP plugin compatibility with featured image modal selection
Expand Down
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"owner":"humanmade","repo":"smart-media","sha":"5264450aeefb1b4737febd74c0fab661d8c18f5f","ref":"refs/tags/0.3.16","tagName":"0.3.16","branch":"gh-actions","tags":["0.3.16"],"updated_at":"2023-03-29T16:45:48.713Z"}
{"owner":"humanmade","repo":"smart-media","sha":"41bf215a1e984874276dd6d027dbe87a945a99dc","ref":"refs/tags/0.4.6","tagName":"0.4.6","branch":"gh-actions","tags":["0.4.6"],"updated_at":"2023-03-29T16:49:10.142Z"}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inc/cropper/media-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<img src="{{ data.model.get( 'url' ) + ( data.model.get( 'url' ).indexOf( '?' ) >= 0 ? '&amp;' : '?' ) }}fit=0,120" width="{{ data.model.get( 'width' ) }}" height="{{ data.model.get( 'height' ) }}" alt="original" draggable="false" />
</button>
</li>
<# if ( data.model.get( 'mime' ).match( /image\/(jpe?g|png|gif)/ ) ) { #>
<# if ( data.model.get( 'mime' ).match( /image\/(jpe?g|png|gif|webp)/ ) ) { #>
<# _.each( data.model.get( 'sizes' ), function ( props, size ) { #>
<# if ( size && size !== 'full' && size !== 'full-orig' ) { #>
<li>
Expand Down
36 changes: 36 additions & 0 deletions inc/cropper/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ function rest_api_fields( WP_REST_Response $response ) : WP_REST_Response {
return $response;
}

// Check if we should skip this one.
if ( skip_attachment( $data['id'] ) ) {
return $response;
}

if ( isset( $data['source_url'] ) && $data['media_type'] === 'image' ) {
$data['original_url'] = $data['source_url'];
$data['source_url'] = tachyon_url( $data['source_url'] );
Expand Down Expand Up @@ -321,6 +326,11 @@ function attachment_js( $response, $attachment ) {
return $response;
}

// Check if we should skip.
if ( skip_attachment( $attachment->ID ) ) {
return $response;
}

$meta = wp_get_attachment_metadata( $attachment->ID );

if ( ! $meta ) {
Expand Down Expand Up @@ -404,6 +414,24 @@ function attachment_js( $response, $attachment ) {
return $response;
}

/**
* Check whether to skip an attachment for Smart Media processing.
*
* @uses filter hm.smart-media.skip-attachment
*
* @param integer $attachment_id The attachment ID to check.
* @return boolean
*/
function skip_attachment( int $attachment_id ) : bool {
/**
* Filters whether to skip a given attachment.
*
* @param bool $skip If true then the attachment should be skipped, default false.
* @param int $attachment_id The attachment ID to check.
*/
return (bool) apply_filters( 'hm.smart-media.skip-attachment', false, $attachment_id );
}

/**
* Updates attachments that aren't images but have thumbnails
* like PDFs to use Tachyon URLs.
Expand All @@ -417,6 +445,10 @@ function attachment_thumbs( $response, $attachment ) : array {
return $response;
}

if ( skip_attachment( $attachment->ID ) ) {
return $response;
}

// Handle attachment thumbnails.
$full_size_thumb = $response['sizes']['full']['url'] ?? false;

Expand Down Expand Up @@ -715,6 +747,10 @@ function filter_attachment_meta_data( $data, $attachment_id ) {
return $data;
}

if ( skip_attachment( $attachment_id ) ) {
return $data;
}

$data = massage_meta_data_for_orientation( $data );

// Full size image info.
Expand Down
2 changes: 1 addition & 1 deletion inc/cropper/src/views/image-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const ImageEditView = Media.View.extend( {
views.push( new Media.view.Spinner() );
} else {
// Ensure this attachment is editable.
if ( this.model.get( 'editor' ) && this.model.get( 'mime' ).match( /image\/(gif|jpe?g|png)/ ) ) {
if ( this.model.get( 'editor' ) && this.model.get( 'mime' ).match( /image\/(gif|jpe?g|png|webp)/ ) ) {
views.push( new ImageEditSizes( {
controller: this.controller,
model: this.model,
Expand Down
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cropper.js": "/inc/cropper/build/cropper.7667462d.js"
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Advanced media tools that take advantage of Rekognition and Tachyon.
* Author: Human Made Limited
* License: GPL-3.0
* Version: 0.3.12
* Version: 0.4.3
*/

namespace HM\Media;
Expand Down

0 comments on commit d31d53f

Please sign in to comment.