isapp/tinyeditor-picture-tag
Composer 安装命令:
composer require isapp/tinyeditor-picture-tag
包简介
Easily convert <img> to responsive <picture> tags for TinyMCE with Laravel helper!
README 文档
README
This helper is designed for Laravel projects and works through model observers triggered after a model is created or
updated.
It transforms the default <img> tags inserted by TinyMCE into <picture> tags, enabling responsive images based on
your predefined configuration.
⚠️ Important:
This helper works exclusively with Spatie Media Library. Make sure the library is installed and properly configured in your project before using this helper.
How It Works
The helper listens for model creation or updates and processes any TinyMCE content by converting <img> tags into
<picture> tags.
This transformation ensures that your images are responsive and optimized for various devices and browsers.
Example: Transformation
Below is an example of how the helper transforms content.
Before Transformation
When an image is inserted into TinyMCE, it looks like this:
<img src="images/example.jpg" alt="Example Image">
After Transformation
After the helper processes the content, the result is:
<picture> <source srcset="images/example.webp" type="image/webp"> <source srcset="images/example.jpg" type="image/jpeg"> <img src="images/example.jpg" alt="Example Image"> </picture>
Installation
You can install the package via composer:
composer require isapp/tinyeditor-picture-tag
Preparing your model
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Isapp\TinyeditorPictureTag\Concerns\InteractsWithTinyeditor; use Isapp\TinyeditorPictureTag\Contracts\HasTinyeditorPictureTag; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; class YourModel extends Model implements HasMedia, HasTinyeditorPictureTag { use InteractsWithMedia; use InteractsWithTinyeditor
Configuration: Setting Up TinyEditor Fields
To configure how TinyEditor content is processed and make images responsive, set up the following method in your model:
public function registerTinyeditorFields(): void { $this->registerTinyeditorField('<field_name>', '<collection_name>') ->registerSource( $this->registerTinyeditorPictureSource('<conversion_name>') ->setWidth(1200) ->setFormat('webp') ->setBreakpointMinWidth(576) ) ->registerSource( $this->registerTinyeditorPictureSource('<conversion_name>') ->setWidth(1200) ->setBreakpointMinWidth(576) ) ->registerSource( $this->registerTinyeditorPictureSource('<conversion_name>') ->setWidth(410) ->setFormat('webp') ) ->registerSource( $this->registerTinyeditorPictureSource('<conversion_name>') ->setWidth(410) ); }
This method configures the content field to generate responsive <picture> tags with multiple image sources based on
the specified breakpoints, widths, and formats.
Documentation
The full documentation for this package is still in progress and will be added soon. Stay tuned for updates!
Contribution
This package was originally created to work seamlessly with Filament and the Filament Forms TinyEditor.
Contributions are welcome! If you have suggestions for improvements, new features, or find any issues, feel free to submit a pull request or open an issue in this repository.
Thank you for helping make this package better for the community!
License
This project is open-sourced software licensed under the MIT License.
You are free to use, modify, and distribute it in your projects, as long as you comply with the terms of the license.
Maintained by ISAPP and ISAP OÜ.
Check out our software development services at isap.me.
isapp/tinyeditor-picture-tag 适用场景与选型建议
isapp/tinyeditor-picture-tag 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 411 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「tinymce」 「laravel」 「laravel-package」 「filament」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 isapp/tinyeditor-picture-tag 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 isapp/tinyeditor-picture-tag 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 isapp/tinyeditor-picture-tag 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Adds links to data objects in TinyMCE editor
TinyMCE Silverstripe 4 inspired theme
A Laravel Package to integrate elFinder 2
A Laravel Nova field that provides integration of TinyMCE.
统计信息
- 总下载量: 411
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-05
