If this filter is enabled and not checked 'Users can override default video sizes', every image's width and height changed by this filter settings in content out of embed or object tags too.

Comments

l@va’s picture

Status: Active » Postponed

This is a known issue, but with my understanding of PHP and regular expressions, I simply do not know how to fix it . The problem occurs in these 2 lines:

 $text = preg_replace('/width=[\'"]?[0-9]{2,}p?[xt]?.?[\'"]?/', "width=\"$width\"", $text);
 $text = preg_replace('/height=[\'"]?[0-9]{2,}p?[xt]?.?[\'"]?/', "height=\"$height\"", $text);

The regular expressions are matching <img stuff="morestuff" width="$width"> in addition to just embed/object/iframe/param. In order to match only these, I would have to prepend a bunch of stuff (whitespace, attributes, etc) in front of the existing regular expressions, which I can do (e.g. /<\s.*?embed[\sa-zA-Z=\d"\';\.]+*width=[\'"]?[0-9]{2,}p?[xt]?.?[\'"]?/), but the problem is the replacement. If I do this, then it ends up changing $TAG_NAME to some fixed tag (e.g. <embed height=$HEIGHT width=$WIDTH src=$mytube_url> becomes width=$WIDTH), and the only thing we want to replace here is the width=NUMBER part. If someone can give me a pointer on replacing a subsection of a larger regular expression, I can fix this pretty easily. Anybody have any ideas?

Until I know how to deal with this specific regular expression problem, the only workaround I can come up with is to turn off enforcement of width/height. If the setting is disabled, MyTube instead tries to parse out the width/height and make sure the thumbnail matches it.

Yaron Tal’s picture

http://php.net/manual/en/function.preg-replace.php

replacement may contain references of the form \\n or (since PHP 4.0.4) $n, with the latter form being the preferred one. Every such reference will be replaced by the text captured by the n'th parenthesized pattern.

So I'd try something like:

$text = preg_replace('/([embed|object|iframe]){1}(.*?)width=[\'"]?[0-9]{2,}p?[xt]?.?[\'"]?/', "\\1\\2width=\"$width\"", $text);

Don't know if it's the way to go though. Regexes aren't my thing either.

mfb’s picture

Version: 6.x-1.0 » 7.x-1.x-dev
Priority: Normal » Major
Issue summary: View changes
Status: Postponed » Active

This is still a problem in the Drupal 7 branch if someone leaves the module with its default settings.

  • mfb committed 6b0d839 on 7.x-1.x
    Issue #1155774: Every image is resized if custom embed sizes are not...
mfb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.