Skip to content

A mime type can be linked to many file formats #13647

Closed

Description

@oparoz

The situation

$imagickProviders = array(
    'SVG'   => 'OC\Preview\SVG',
    'TIFF'  => 'OC\Preview\TIFF',
    'PDF'   => 'OC\Preview\PDF',
    'AI''       => 'OC\Preview\Illustrator',
    'PSD'   => 'OC\Preview\Photoshop',
    'EPS'   => 'OC\Preview\Postscript',
);

foreach ($imagickProviders as $queryFormat => $provider) {
    if (count($checkImagick->queryFormats($queryFormat)) === 1) {
        self::registerProvider($provider);
    }
}

The key is the name of a format supported by ImageMagick

  • Only one format is linked to a preview provider class. It's an arbitrary decision
  • A preview class can only be activated once or it will be loaded several times in the $registeredProviders` array.

The problem

We can't always know which formats the admin is going to enable in ImageMagick to support a certain family of files.

An example with Font files

The check in Preview
TTF' => 'OC\Preview\Font

Some formats supported by ImageMagick

  • TTF
  • OTF

Extension enabled

  • OTF

The system will determine that font preview has to be disabled.

Solutions

One solution would be to add all the formats as keys and for registerProvider to check if a class is already registered before adding it to the array.

Activity

  1. oparoz commented on Jan 24, 2015

    @oparoz
    ContributorAuthor

    I'll give you a better example. Those are the RAW formats supported by ImageMagick

    • arw
    • cr2
    • dcr
    • dng
    • erf
    • iiq
    • kdc
    • k25
    • nef
    • mef
    • orf
    • rw2
    • pef
    • raf
    • srf
    • sr2
    • xrf

    You can't just pick one

  2. oparoz commented on Jan 24, 2015

    @oparoz
    ContributorAuthor
  3. added this to the milestone on Jan 26, 2015
  4. oparoz commented on Feb 23, 2015

    @oparoz
    ContributorAuthor

    Updated the OP to better describe the problem

  5. PVince81 commented on Apr 23, 2015

    @PVince81
    Contributor

    Moving to 8.2 (enhancement)

  6. modified the milestones: , on Apr 23, 2015
  7. PVince81 commented on Sep 21, 2015

    @PVince81
    Contributor

    Moving to 9.0 as we're past feature freeze

  8. modified the milestones: , on Sep 21, 2015
  9. 1 remaining item

  10. ghost removed this from the milestone on Feb 23, 2016
  11. modified the milestones: , on Jun 14, 2016
  12. modified the milestones: backlog, 10.0 on Jan 27, 2017
  13. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions