Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/humanmade/smart-media
Smart Media enhancements for WordPress
https://github.com/humanmade/smart-media
aws-rekognition machine-learning wordpress
Last synced: about 1 month ago
JSON representation
Smart Media enhancements for WordPress
- Host: GitHub
- URL: https://github.com/humanmade/smart-media
- Owner: humanmade
- Created: 2018-07-24T09:31:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-13T11:16:16.000Z (about 1 month ago)
- Last Synced: 2024-11-13T12:08:58.984Z (about 1 month ago)
- Topics: aws-rekognition, machine-learning, wordpress
- Language: PHP
- Homepage:
- Size: 2.49 MB
- Stars: 83
- Watchers: 26
- Forks: 7
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
Smart Media
Enhanced media library features for WordPress.
A Human Made project. Maintained by @roborourke.
Smarter media features for WordPress.
Some features in this plugin will work on their own however some are designed to augment the existing tools we use such as [Tachyon](https://github.com/humanmade/tachyon).
## Features
### Justified media library
The media library shows square thumbnails by default which can make it harder to find the right image. This feature makes the thumbnails keep their original aspect ratio, similar to the UI of Flickr.
To disable the feature add the following:
```php
`
- `smartmedia.cropper.selectSizeFromBlockAttributes.`In the above filters `` should be replaced a dot separated version of your block name, for example `core/image` becomes `core.image`. The core image block attributes are mapped by default.
Mapping the selected image to block attributes:
```js
addFilter(
'smartmedia.cropper.updateBlockAttributesOnSelect.core.image',
'smartmedia/cropper/update-block-on-select/core/image',
/**
* @param {?Object} attributes The filtered block attributes. Return null to bypass updating.
* @param {Object} image The image data has the following shape:
* {
* name: , The image size name
* url: , The URL for the sized image
* width: , The width in pixels
* height: , The height in pixels
* label: , The human readable name for the image size, only present for user selectable sizes
* cropData: , Null or object containing x, y, width and height properties
* }
*/
( attributes, image ) => {
// Only user selectable image sizes have a label so return early if this is missing.
if ( ! image.label ) {
return attributes;
}return {
sizeSlug: image.size,
url: image.url,
};
}
);
```Update the cropping UI selected size based on selected block attributes:
```js
addFilter(
'smartmedia.cropper.selectSizeFromBlockAttributes.core.image',
'smartmedia/cropper/select-size-from-block-attributes/core/image',
/**
* @param {?String} size The image size slug.
* @param {Object} block The currently selected block.
*/
( size, block ) => {
return size || block.attributes.sizeSlug || 'full';
}
);
```The function takes 2 parameters:
- `block`: The name of the block to map attributes for
- `callback`: A function that accepts the image `size` name, an `image` object containing `url`, `width`, `height`, crop data and label for the image size, and lastly the full `attachment` data object.The callback should return an object or `null`. Passing `null` will prevent updating the currently selected block.
## Roadmap
Planned features include:
- Duplicate image detection and consolidation
- EXIF data editor## Contributing
First of all thanks for using this plugin and thanks for contributing!
To get started check out the [contributing documentation](./CONTRIBUTING.md).