Dealing with Images Insertion

Got something you want in the core? Missing features, new toys? Then this is the place to start it off

Moderator: Dracones

Re: Dealing with Images Insertion

Postby EdB » Wed Jul 28, 2010 2:14 am

Code: Select all
         function tinymce_plugin_cleanup_callback( type, value )
         {
            switch( type )
            {
               case 'insert_to_editor' : // called when textarea converted to tiny
               case 'insert_image_tags' : // called when inserting image from fileman
                  direction =
                  value = value.replace( /<span( class=\"imgwrap[^>]+>)(.+?<\/span>)<\/span>/g, '<table border="1" align="right"$1<tr><td>$2</td></tr></table>' );
                  break;

               case 'get_from_editor' : // called on preview/save pressed
                  value = value.replace( /<table([^>]+imgwrap[^>]+>).+?<td>(.+?)<\/td>.+?<\/table>/g, '<span$1$2</span>' );
                  value = value.replace( / border="1" align="right"/g, '' );
                  break;
            }
            return value;
         }

I think the whole idea behind "imgwrap" doesn't matter. I think it can go away. I'm not sure what the "center" does either, meaning I don't think it actually does anything. Anyway what I have no idea how to do is tweak that regex to find which way the span was floating and use that in place of where I'm forcing the table to align right. Something about writing regexes makes my head explode. Having said that, it seems to me if we can extract out which direction each image is floating then we can use that where I'm forcing the table align to be "right", and if we can do that then I think this issue is completely resolved. A span for an image with or without a caption that looks like a properly floated table if you're using TinyMCE.

Oh and I did not commit this change to the server. I did commit to having no 'close' button, and might commit this, but I am going to see if the imgwrap actually does anything or if it can go byebye.
EdB
Dracone
User avatar
 
Posts: 1467
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: Dealing with Images Insertion

Postby EdB » Wed Jul 28, 2010 7:28 am

Someone pls check out the branch https://code.launchpad.net/~quam-plures ... nts_popups as I now have it capable of immediately having a visible border and floating images left or right when using TinyMCE. The string.replace to put it back together is fairly sloppy and hackish and I've no idea why it didn't work in simpler iterations, but it most certainly does seem to work.

Oh snap I guess I should be checking out doing it with uncaptioned images. Or maybe someone else will?
EdB
Dracone
User avatar
 
Posts: 1467
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: Dealing with Images Insertion

Postby Yabs » Wed Jul 28, 2010 8:17 am

See my note on your other thread

¥
I may have opened the door but you entered of your own free will

Image Techno Babble II
Image Tacky Pad 3
Yabs
Dracone
User avatar
 
Posts: 819
Joined: Sat Nov 21, 2009 9:59 am

Re: Dealing with Images Insertion

Postby EdB » Wed Jul 28, 2010 9:11 am

Just got done chatting with Yabs. This has hurt us for time. Not that we have a deadline or anything, but v0 doesn't happen until some serious shit gets done. And not that being able to use TinyMCE effectively and easily while still producing well-formed html isn't serious, but we figured it is best to pull these efforts out of the popups branch and push them into their own branch so we can go forward on the stuff we're kinda good with. Then the "floating captioned images with TinyMCE" issue can be resolved on it's own.

We got so friggin close too.

Oh and just to capture a note from the chat session: possibly a psuedo-hook to clean up details after an editor closes and before storing the content? Possibly making TinyMCE be a 'renderer' so it can use a hook that could easily convert the table to a span again but is for renderers only? Anyway it seems like "convert to table inside TinyMCE and back to a span outside TinyMCE" is the way to go on this.

EDIT: https://code.launchpad.net/~quam-plures ... es_in_tiny is the new branch for this
EdB
Dracone
User avatar
 
Posts: 1467
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: Dealing with Images Insertion

Postby Kimberly » Thu Jul 29, 2010 4:52 pm

EdB wrote: it seems like "convert to table inside TinyMCE and back to a span outside TinyMCE" is the way to go on this.


I don't agree with this at all as the table does the job and is valid markup within the W3C specifications. I am going to continue to work on this as a solution to the problem of images with captions even if is just for my own local implementation of QP.

Thanks EdB for all the work you put into this.

-Kimberly
Kimberly
 
Posts: 83
Joined: Mon Jul 19, 2010 4:44 pm

Re: Dealing with Images Insertion

Postby Yabs » Thu Jul 29, 2010 5:40 pm

To implement it you just need to modify the code in ... urm, bugger forgotten the file .... urm qp_inc/_files/view/file_list.inc.php or summat, where it wraps it in spans

Ideal solution is to make it work for all instead of multiple solutions for various people ... and we (I'll) work on that once the converter is coded and as bug free as I can make it ( with everyones help of course) because the lack of a converter is stalling us from reaching ground zero :(

¥
I may have opened the door but you entered of your own free will

Image Techno Babble II
Image Tacky Pad 3
Yabs
Dracone
User avatar
 
Posts: 819
Joined: Sat Nov 21, 2009 9:59 am

Re: Dealing with Images Insertion

Postby Kimberly » Thu Jul 29, 2010 10:33 pm

The funny thing is that the w3C was gong to add this (captions) to HTML 5 specification and decided to drop it. It would have been a part of the new image tag. I played with this some more today and in the end I could have been doing something more constructive. In my play, I did discover that the new TinyMCE does not support the adding of styles by the use of the content.css so something constructive did come out of it; posted a new topic in the bugs section if that was the place for it.

For now, I guess the solution for those using the editor and wanting to insert an image they included a caption with would be that if they want to change the float they have to delete the image and re-insert it until a better solution is found. The problem with the messing visual cue on insertion of a table with border="0" by the file manage is a TinyMCE error. Inserting a table with border="1" by the file manager showed the border. It seems that without a border the editor does not trip the "show visual cue" right after the table is inserted, but does trip it if you switch to html and then back to wysiwyg.
Kimberly
 
Posts: 83
Joined: Mon Jul 19, 2010 4:44 pm

Previous

Return to Propose a blueprint

Who is online

Users browsing this forum: No registered users and 1 guest