What does it do? 

This extension provides automatic conversion of wrong suffixed images.

Example 

Your customer provides an image taken with iPhone, which is saved as image type *.heic/*.heif. This is not possible to upload to TYPO3. Customer changes file suffix from .heic to .jpg. This will be uploaded to TYPO3, but metadata extractors can't handle exif data.

To correct this behaviour, this extension ships an event listener to check.

Workflow 

  1. Event listener checks for suffix matching mime type
  2. Listener calls FileConverterRegistry to detect possible Converter
  3. Registry serves ConvertProvider
  4. Listener calls ConvertProvider
  5. ConvertProvider converts to mime type expected from file suffix
  6. Uploaded file is overwritten by correct file matching mime type

Contribution 

Contributions are essential to the success of open source projects, but are by no means limited to contributing code. Much more can be done, for example by improving documentation.

Contribution workflow 

  1. Please always create an issue on Github before starting a change. This is very helpful to understand what kind of issue the pull request will solve and if your change will be accepted.
  2. Bug fixes: Please describe the type of bug you want to fix and provide feedback on how to reproduce the problem. We will only accept bug fixes if we can reproduce the problem.
  3. Features: Not every feature is relevant to the majority of the users. In addition: We do not want to make this extension more complicated in usability for a marginal feature. It helps to have a discussion about a new feature before opening a pull request.
  4. Please always create a pull request based on the updated release branch.

Developer 

Adding own ConverterProvider 

Adding an own ConverterProvider is easy:

<?php

namespace MyVendor\MyExt\Converter\Provider;

use WebVision\MimeConverter\Converter\AbstractFileConverter;

class MyConverterProvider extends AbstractFileConverter
{
    public static function canConvert(string $mimeType, string $expectedMimeType): bool
    {
        // check if converter can convert mime types
    }

    public function convert(
        string $originalFile,
        string $setMimeType,
        string $expectedMimeType
    ): bool {
        // convert file
    }
Copied!

For help in conversion handling, look into WebVisionMimeConverterConverterProviderImageConverterProvider and use, if needed WebVisionMimeConverterServiceMimeTypeDetectorService.

Register FileConverterProvider 

Register your Provider inside Services.yaml

services:
  MyVendor\MyExt\Converter\Provider\MyConverterProvider:
    tags:
      - name: mime.converter
        identifier: my_identifier
Copied!