定制 wapplersystems/font-downloader 二次开发

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

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

wapplersystems/font-downloader

Composer 安装命令:

composer require wapplersystems/font-downloader

包简介

Automatically downloads external CSS fonts (Google Fonts, Font Awesome, ...) and serves them locally for GDPR compliance

README 文档

README

Automatically downloads external CSS fonts and serves them locally. This improves GDPR compliance and page performance by eliminating third-party requests.

Installation

composer require wapplersystems/font-downloader

Requirements

  • TYPO3 v14
  • PHP 8.2+

Usage

Simply include external font CSS via TypoScript as usual:

page.includeCSS {
  opensans = https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap
  fontawesome = https://use.fontawesome.com/releases/v5.15.4/css/all.css
}

The extension automatically intercepts these external URLs, downloads the CSS and all referenced font files, stores them locally in typo3temp/assets/font-loader/, and rewrites the references. No further configuration needed.

Supported font providers

  • Google Fontsfonts.googleapis.com/css
  • Font Awesomefontawesome.com/releases

Adding a custom font loader

You can add support for additional providers by implementing FontLoaderInterface:

<?php

declare(strict_types=1);

namespace Vendor\MyExtension\FontLoader;

use WapplerSystems\FontDownloader\FontLoader\AbstractFontLoader;

class MyFontLoader extends AbstractFontLoader
{
    protected string $identifier = 'myprovider';

    public function isResponsible(string $url): bool
    {
        return str_contains($url, 'myprovider.com');
    }
}

Tag the service in Configuration/Services.yaml:

services:
  Vendor\MyExtension\FontLoader\MyFontLoader:
    tags: ['fontloader']

The load() method is inherited from AbstractFontLoader and handles downloading automatically.

Cache

Downloaded fonts are cached with infinite lifetime. To force a re-download:

vendor/bin/typo3 cache:flush --group=system

License

GPL-2.0-or-later

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固