Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The attached patch adds media-image-left
and media-image-right
(along with the existing media-image
class to give themers more control over styling embedded images. These classes are added whenever the style float: left
or float: right
are added.
This was originally raised in this issue, but was moved to it's own issue to avoid confusion. Note that unlike the patch in #1043570: Floating images left and right, this patch does not add any default styling for these new classes. It just adds the classes.
Comment | File | Size | Author |
---|---|---|---|
add-float-classes.patch | 1.11 KB | mikeker | |
Comments
Comment #1
rootwork+1 on this!
Will try to test it out shortly and report back.
Comment #2
mrfelton CreditAttribution: mrfelton commented+1
Comment #3
dboulet CreditAttribution: dboulet commentedYes, this would be great.
Comment #4
dboulet CreditAttribution: dboulet commentedPatch works well for me. I’m going to move this to the 2.x branch since it seems to be the main focus for development at the moment.
Comment #5
mikeker CreditAttribution: mikeker commented@dboulet: just to clarify, you used the patch against the 2.x branch and it was working fine?
Anyone willing to mark this RTBC? I'd love to see this added so I don't have to patch Media with each install. :)
Comment #6
dboulet CreditAttribution: dboulet commentedYes, it works fine on 2.x as well. The only thing that I think we should add is default CSS so that the floating works out of the box.
Comment #7
mikeker CreditAttribution: mikeker commentedI thought about that (see the original patch, I had added some basic spacing around the image), but decided it was cleaner to leave that out. The floating should work out of the box as Media adds style="float: left" (or right) to the img tag. Please comment here if you DO NOT see the floats added and I can amend the patch. I haven't had a project using Media 2.x yet...
Comment #8
dboulet CreditAttribution: dboulet commentedI see, I forgot that in my case I have an input filter that removes all inline styles. I like the idea of adding the spacing around the image, I think its worth adding. The CSS in your original patch looks good to me.
Comment #9
aaron CreditAttribution: aaron commentedworks as advertised. i wonder about the notation of -1 != $var though; don't the drupal standards flip that?
Comment #10
mikeker CreditAttribution: mikeker commentedThe
CONST == $variable
order is a left over from a very embarrassing checkin I made about 16 years ago at a large, not-to-be-named-but-located-in-Redmond-WA software company. It was a typicalif ($var = CONST)
supposed-to-be-a-conditional-but-ooops bug that ended up shipping.I blamed beer, but my boss blamed me. Can you imagine? :)
From then on, I trained myself to write
if (CONST == $var)
as that gives you a compile error if you leave out one of the '=' by accident. Granted, it doesn't matter with a not-equals, mostly force of habit at this point.Anyhow, the Drupal coding standards and Drupal JS coding standards are mum on the topic. (Unless I missed it... in which case I'll blame beer again).
I'm happy to flip the conditionals if you like. I just want to see the patch committed so I don't have to re-patch Media with each upgrade! :)
Thanks, aaron.
Comment #11
JacobSingh CreditAttribution: JacobSingh commentedFixed in 7.2.x There are probably other larger fixes we have to make to the WYSIWYG style handling code, but this is a start to something people really need.
Nice work!
Comment #12
rootworkWoohoo!
Comment #14
FiNeX CreditAttribution: FiNeX commentedCurrent 2.x-dev doesn't have this feature. Has it been moved to an external module?
Comment #15
arthurf CreditAttribution: arthurf commentedNote that there are new classes in 2.x from this issue: http://drupal.org/node/1872420 it does not have left/right support, but there are more theming options now.
Comment #16
jeremiahtre.in CreditAttribution: jeremiahtre.in commentedLast seen in 7.x-2.0-unstable6. Definitely not in dev.
Comment #17
mikeker CreditAttribution: mikeker commentedLooks like the fix for this issue got dumped as part of the fix for #1451316: Clean up wysiwyg-media.js. I haven't had a chance to read through that thread as it's a fairly thorough refactoring of
wysiwyg-media.js
. It might be worth posting a comment in that issue to see if this was an intentional removal or if it should've been moved elsewhere in the code.Please cross-post if anyone does inquire. Unfortunately, I don't have time to look into this further at the moment...
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commentedlets move this over to #1885432: Figure out a way to keep markup output consistent in media embeds