定制 humanmade/smart-media 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

humanmade/smart-media

Composer 安装命令:

composer require humanmade/smart-media

包简介

Smart Media features for HM Cloud

README 文档

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.

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
add_filter( 'hm.smart-media.justified-library', '__return_false' );

Image editor

This feature overrides the built in WordPress image editing experience and gives you control over the crops of individual thumbs. There are also some UX improvements meaning there are fewer clicks required to make edits.

To disable the feature add the following:

<?php
add_filter( 'hm.smart-media.cropper', '__return_false' );

The image cropping UI provides support for updating Gutenberg block attributes based on the current selection using the following filters:

  • smartmedia.cropper.updateBlockAttributesOnSelect.<block name>
  • smartmedia.cropper.selectSizeFromBlockAttributes.<block name>

In the above filters <block name> 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:

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: <string>,  The image size name
   *     url: <string>,  The URL for the sized image
   *     width: <int>,  The width in pixels
   *     height: <int>,  The height in pixels
   *     label: <string>,  The human readable name for the image size, only present for user selectable sizes
   *     cropData: <?object>,  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:

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.

humanmade/smart-media 适用场景与选型建议

humanmade/smart-media 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 236.17k 次下载、GitHub Stars 达 89, 最近一次更新时间为 2018 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 humanmade/smart-media 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 humanmade/smart-media 我们能提供哪些服务?
定制开发 / 二次开发

基于 humanmade/smart-media 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 236.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 89
  • 点击次数: 11
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 89
  • Watchers: 23
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-09-19