Coder Social home page Coder Social logo

Comments (14)

damienalexandre avatar damienalexandre commented on May 27, 2024 7

👍 for this feature in the core!

from twig-extensions.

fabpot avatar fabpot commented on May 27, 2024 3

implemented in Twig core (see twigphp/Twig#3102)

from twig-extensions.

romainneutron avatar romainneutron commented on May 27, 2024

Probably a binding to this lib is a good way ? https://github.com/alchemy-fr/PHP-dataURI

@nlegoff This is for you

from twig-extensions.

cryptocompress avatar cryptocompress commented on May 27, 2024

https://github.com/cryptocompress/DataUrlTwigExtension/blob/master/CryptoCompress/TwigBundle/Extension/DataUrlTwigExtension.php

(mime-type detection is missing)

from twig-extensions.

snc avatar snc commented on May 27, 2024

for mime-type detection you can check this Symfony2 classes/code:

from twig-extensions.

cryptocompress avatar cryptocompress commented on May 27, 2024

you are right. i tested this:
http://pastebin.com/Hi07BaEE

some drawbacks:

  • class "MimeTypeGuesser" is a Singleton
  • my webhoster disabled Fileinfo ext
  • my webhoster disabled "passthru" method
  • method "mime_content_type" is deprecated
  • there is no posibility to catch the exception (\LogicException SPL?) cleanly (no code)
  • in class File\File there is an protected "mime-type => extension" array ($defaultExtensions). with array_flip i might map this...
    BUT:
    in rfc2397 mime-type ([]) is optional. so it works entirely without mime-type or with text/plain... it doesnt matter :)

from twig-extensions.

romainneutron avatar romainneutron commented on May 27, 2024

Be carefull, your implementation does not check the string length to comply with RFC 2397 section 2 https://www.ietf.org/rfc/rfc2397.txt

from twig-extensions.

romainneutron avatar romainneutron commented on May 27, 2024

Here's my implementation, based on PHP-dataURI

https://github.com/romainneutron/TwigExtension-DataUri

from twig-extensions.

cryptocompress avatar cryptocompress commented on May 27, 2024

RFC 1866 Hypertext Markup Language - 2.0 November 1995
The `NAMELEN' parameter in the SGML declaration (9.5, "SGML Declaration for HTML") limits the length of an attribute value to 1024 characters.

BC can be overdone :)
and except for mixing datatypes, i like your solution...

from twig-extensions.

 avatar commented on May 27, 2024

👍

from twig-extensions.

webdevilopers avatar webdevilopers commented on May 27, 2024

👍

from twig-extensions.

Maelstromeous avatar Maelstromeous commented on May 27, 2024

👍

from twig-extensions.

nateclonch avatar nateclonch commented on May 27, 2024

👍

from twig-extensions.

obax avatar obax commented on May 27, 2024

👍

from twig-extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.