paulund/og-image-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

paulund/og-image-generator

最新稳定版本:2.1.0

Composer 安装命令:

composer require paulund/og-image-generator

包简介

Laravel OG Image Generator

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

OG Image Generator Laravel Package

Laravel package to automatically create a og image that the page generates when it's saved to social media.

Table Of Contents

Installation

You can install the package via composer:

composer require paulund/og-image-generator
npm install puppeteer
php artisan vendor:publish --provider="Paulund\OgImageGenerator\OgImageGeneratorServiceProvider"

In the <head></head> tag of your application you need to add the meta og-image tag. Pointing to the route created by the package and passing in a variable of $ogTitle which is the text that will appear on the generated image.

<meta property="og:image" content="{{ route('og-image', ['title' => $ogTitle ]) }}" />

Configuration

There is no configuration required for this package. The package will automatically start generating Open Graph images for social media sharing.

But you can configure the package by publishing the config file, which will allow you to change the following configs.

  • Image mime type - default is png
  • Storage disk - default is local
  • Storage path - default is public/og-images
  • Extra data - you can add extra data to the image that will be passed to the view

Config Styling

By default OG Image Generator comes with tailwinds css installed on the page and you can customise the styling of the image by changing the tailwind classes in the config file.

'styling' => [
    'background' => 'bg-gray-900',
    'text' => 'text-white',
],

Customise The View

If you'd like you use your own blade view file then you can change the view config in the config file.

'view' => env('OG_IMAGE_GENERATOR_VIEW', 'paulund/og-image-generator::image'),

Or you can change the view in the .env file.

OG_IMAGE_GENERATOR_VIEW=your-view-file

Extra Data

If you want to pass extra data to the view then you can add it to the config file.

'extra' => [
    'logo'
    'author'
],

When this is passed into the request it will be available in the view as $extra['logo'] and $extra['author'].

Delete Old Images

There is a command that you can run to delete all the old images that have been created by the package.

php artisan og-image:delete-old-images

This command will delete all the images that are older than 90 days.

This command is added to the Laravel scheduler to run every day.

Testing

vendor/bin/testbench workbench:install
composer check

Credits

License

The MIT License (MIT). Please see License File for more information.

Tutorial

To learn more about how this work you can read the tutorial on Paulund

paulund/og-image-generator 适用场景与选型建议

paulund/og-image-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.66k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2024 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「og」 「laravel」 「meta」 「Paulund」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 paulund/og-image-generator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 12
  • 依赖项目数: 1
  • 推荐数: 2

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-09-10