Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64 inline image kills the plugin #2

Closed
5DOC opened this issue Jan 27, 2014 · 3 comments
Closed

Base64 inline image kills the plugin #2

5DOC opened this issue Jan 27, 2014 · 3 comments

Comments

@5DOC
Copy link

5DOC commented Jan 27, 2014

Hi Chris

Great plugin!

I tried to add this to a post with base 64 inline images but it killed the output.

Sample base64 data (also be used with audio and video binaries):
<img src="data:image/jpeg;base64,{IMAGE DATA HERE (braces not included)}” alt="name" width="XXX" class="alignleft size-full wp-image-xxx">

Sample base64 data: 0dv4X1oaaWoFc30BEaXvSHWwJGsH9aVtfnpalF508KBW

There is nothing to minify here.

Is there a simple way to add to your code to ignore everything inside img, audio and video tags? There are no "<" or ">" inside base64 data but there are "/".

I see this:
if ($tag == 'pre' || $tag == 'textarea') {
$raw_tag = $tag;
}
else if ($tag == '/pre' || $tag == '/textarea') {
$raw_tag = false;
}

But these media tags don't have closing tags, only brackets.

I also saw in your code regular expressions for CSS and Javascript, but they also have closing tags.

I was thinking of 2 options:

  1. A regex that switches to raw from
    For example to add in the $pattern: /<(?img).*>
  2. Add an exclusion similar to 'pre' for 'figure'

What would you suggest?

Cheers
Mike

@cferdinandi
Copy link
Owner

@mikeperlman - I noticed that, too. The minification code was forked from DVS. My contribution was converting it into a standalone plugin and adding an options page, so I'm not really sure where to start. As data-urls for images become more common, though, this will definitely be an ongoing issue, so I'm glad you started an issue for it.

@5DOC
Copy link
Author

5DOC commented Jan 27, 2014

OK, I discovered that "" is toggle on and toggle off.
Ironically the img tag is the biggest problem as audio and video have closing tags - so I could adapt the toggle code for them and also for figure and embed tags and any other ones that need to have compression off for their contents.

@cferdinandi
Copy link
Owner

@mikeperlman - It's been a while since I've dug through that script, so if you had the time and desire to try fixing this bug, I'd be most grateful! And if you don't, I completely understand.

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

No branches or pull requests

1 participant