定制 mapado/image-url-builder 二次开发

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

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

mapado/image-url-builder

Composer 安装命令:

composer require mapado/image-url-builder

包简介

Generate a full url from an image slug

README 文档

README

Generate a full url from an image slug

Installation

composer require mapado/image-url-builder

Usage

use Mapado\ImageUrlBuilder\Builder;

$builder = new Builder();

$width = 800;
$height = 600;
$url = $builder->buildUrl('2018/01/foo.jpg', $width, $height);

// will output '//img.mapado.net/2018/01/foo_thumbs/800-600.jpg'

The first parameter of the buildUrl function accept an image "slug" or a full image url (starting with https://img.mapado.net/)

Force http(s) prefix

If you want to force http prefix, you can use the withHttpPrefix() or withHttpsPrefix() function before :

$httpUrl = $builder
    ->withHttpPrefix()
        ->buildUrl($slug, $width, $height);
// will output `http://img.mapado.net/xxxx...`

$httpsUrl = $builder
    ->withHttpsPrefix()
        ->buildUrl($slug, $width, $height);
// will output `https://img.mapado.net/xxxx...`

With Twig

A Twig extension is available : Mapado\ImageUrlBuilder\Twig\UrlBuilderExtension

You need to inject an instance of Mapado\ImageUrlBuilder\Builder to the constructor.

If you are using Symfony, the following configuration do work fine:

services:
  Mapado\ImageUrlBuilder\Builder: ~

  Mapado\ImageUrlBuilder\Twig\UrlBuilderExtension:
    tags:
      - { name: twig.extension }

You can use the filter like this:

<img src="{{ imageSlug|imageUrl(width, height) }}" />

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固