Skip to content


add a base64 encoding filter #54

lsmith77 opened this Issue · 8 comments

5 participants


this can be convenient for inlining images. the filter should accept a variable containing a binary string, a stream resource and maybe also just a filename.


Probably a binding to this lib is a good way ?

@nlegoff This is for you


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


you are right. i tested this:

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 :)

Be carefull, your implementation does not check the string length to comply with RFC 2397 section 2


Here's my implementation, based on PHP-dataURI


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...


:+1: for this feature in the core!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.