Seems this module could inserting anything into the body copy, no?
What would it take to integrate the emfield module?
Similar request here http://drupal.org/node/459704

CommentFileSizeAuthor
#6 insert_ajax_emfield.patch13.79 KBquicksketch

Comments

quicksketch’s picture

The section of code that actually inserts code into the textarea or WYSIWYG is about 50 lines, the other 100 lines of the filefield_insert.js file and about 200 lines in filefield_insert.module is building up the template to actually be inserted into the textarea. Expanding to other modules like emfield would probably require a significant increase in code. In any case, this module is purely experimental and probably won't be released or expanded in any official way until I can get #417122: Allow drupal_alter() on Field and Widget Settings into CCK, because right now the whole thing is way to hacky and unstable without an adequate place to store settings.

quicksketch’s picture

Project: FileField Insert » Insert
Version: 6.x-1.x-dev » 6.x-1.0-beta1

I've renamed this module to Insert to accommodate this exact problem. The new module can be used with any CCK field, though I've only just ported over the existing support for FileField/ImageField. It should definitely be possible to add this support to emfield or other fields, though for emfield I'm not sure if you'd get any benefit, since it's entire purpose is avoiding inline embed tags.

Moving to Insert module in case we want to continue this discussion.

pribeh’s picture

Hi quicksketch,

As a themer, I'd love to see this implementated. I'm using cck fields (so imagefield instead of say image) primarily because they are so easy to theme and they can provide great ease for users interfacing with Drupal (insert image here, then insert image to text here). I love the insert whatever to text here workflow. The few users I've tested this with (using imagefield) love it and find it intuitive.

So the theming advantage of having video in a CCK field is that I can detect and theme for it easily as follows:

if teaser then ...
if field_image print field_image
if field_video_thumbnail print field_video_thumbnail

This way by ensuring major pieces of content are in their own field, even if they're inserted inline, us designers get to easily pull it out again for theming purposes. So having the additional ability for users to insert a video anywhere in the text area increases the options for users to alter the layout of a node (say page-blog) the way they want without removing the ease of theming/rearranging content for other displays (say teaser-blog).

Sorry if I'm just rambling.

Thomas

quicksketch’s picture

Makes sense, thanks Thomas for explaining the use-case for your users. Anyway I'd be happy to include more implementations with Insert for reasonably popular modules, such as emfield or swftools. Depending on how big the project is or what it's focus is, I might also recommend that module implement Insert hooks in that module instead, since the module author will retain more control and be able to update the code as their APIs change.

johngriffin’s picture

I've been looking for a way to cleanly insert video into the body for a while and this might well be the best method. I should get some time to code insert support for emfield sometime over the next week. I'm guessing it shouldn't take too long, am I right in thinking that I will just have to implement:

hook_insert_widgets() - to describe where to inject our insert widget

hook_insert_styles() - to return some format options (thumbnail, full-size for example)

hook_insert_content() - to return the HTML to be inserted into the body

Am I right in that thinking? If you could write some documentation on the hooks and how to write an implementation for a new module that would be massively helpful!

Thanks :)

quicksketch’s picture

Status: Active » Needs work
StatusFileSize
new13.79 KB

Hey johngriffin, I'm actually in the middle of an emfield implementation. The trouble with emfield is that it requires some very tricky AJAX calls to actually generate the HTML that needs to be inserted into the textarea. For example if the user posts a string into an emfield, we don't necessarily know if that's a YouTube ID or a Blip.tv ID. We actually need to ask emfield what kind of ID it is and what kind of markup that should output.

So I'd suggest standing by until that gets finished, though if you're interested here's the work I have so far (definitely NOT working at this point).

johngriffin’s picture

Ok I'll wait on this patch. Do you have any idea of timescale? Does emfield provide an API to return the content for a video field, or are we relying on some hacky method which is subject to change when emfield is updated? If so perhaps we should put something in the emfield queue to let them know?

johngriffin’s picture

Hi quicksketch,

I will have some time this coming week to work on this, so if you have done anything further on it could you please post your code so far and a list of todos?

thanks,
John

quicksketch’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev

I have not made any further progress on this fyi. If I'm working on it I'll post here.

aaron’s picture

i didn't know about this issue. i'll see what i can do to help -- btw, we've done this w/ the media module using placeholder images rather than embed code when in the browser, which seems to work fine there. also, emfield includes eminline, so maybe its functionality could be tapped.

fallsemo’s picture

Subscribe. I can help test :)

danny englander’s picture

Subscribing

AdrianB’s picture

Subscribing.

quicksketch’s picture

Title: Inserting Media into body copy of a WYSIWYG textarea. » Work with other CCK fields besides FileField/ImageField (Node Reference, Text, Emfield, etc)

Retitling to consolidate all the various issues.

stella’s picture

subscribe

mrfelton’s picture

subscribe

adub’s picture

Blocks also would be incredibly useful.

lubnax’s picture

Subscribe

mmaul’s picture

Subscribing :) I would love to see integration of the imagefield_crop module, which is what I use for 90% of client websites where non-tech users are editing content.

quicksketch’s picture

ImageField Crop should work without any of these changes see the issue over in their queue: #639578: Support for Insert?

pelicani’s picture

Excited for the dv7 version of Media.
It will handle all of our media woes.

But it isn't out yet and most of our sites won't be upgraded to get this feature.
I'll take a look at the patch above.
Perhaps others will help and we can get this useful feature up and running.

rhimes’s picture

subscribe

Would like to see Embed Google Maps Field (http://drupal.org/project/embed_gmap) as well!

OpenChimp’s picture

This is a great subject. I can't wait to see what comes of this...

pribeh’s picture

Plus twenty six fist pumps and pushups for embed_gmap support.

mstrelan’s picture

mstrelan’s picture

@quicksketch - would it make it easier to implement if the insert button could just insert a token, for example for a video or a google map? In my experience the average user is not smart enough to use tokens on their own, but if they can upload a file and click insert and a token is displayed then I think this is a good start.

quicksketch’s picture

@quicksketch - would it make it easier to implement if the insert button could just insert a token, for example for a video or a google map?

Insert *could* insert anything, it just depends on the implementation of hook_insert_styles() and what theming is applied. In such a case, the theming could just be the contents of a token. In the same way, Insert module could be made to use BBCode or any other system also.

volongoto’s picture

Subscribing.

Melissamcewen’s picture

subscribe, particularly would be useful for node reference

andyf’s picture

subscribe - also interested in nodereferences

kingjohnnet’s picture

subscribe

coworksbe’s picture

subscribe

paganwinter’s picture

+1 for nodereference (in a way that even when a site to moved to a different domain, all links to internal pages in the content work smoothly)
Think Linodef.

mstrelan’s picture

@paganwinter - not sure you understand what nodereference fields are. But it sounds like you want the Internal path filter module.

lpalgarvio’s picture

add support for Image fupload :P
http://drupal.org/project/image_fupload

this one can upload multiple images to a single node or multiple images to corresponding new nodes.

lpalgarvio’s picture

image_fupload is a widget for imagefield.

zuriwest’s picture

@quicksketch: what is your road map with 6.x and emfield? Has there been any development on the patch started back in November of 09?

achton’s picture

Subscribing.

mstrelan’s picture

On the weekend I attended DrupalDownunder in Brisbane and the author of http://drupal.org/project/wysiwyg_imagefield spoke about his plans to incorporate this functionality in a generic way in a new version of wysiwyg_imagefield. I would suggest collaboration if this is not already happening.

J.B-2’s picture

Yes, just came across it: Wysiwyg Fields, basically seems to do a very similar thing: https://github.com/Decipher/wysiwyg_fields

willieseabrook’s picture

+1 for nodereference support. subscribing

deciphered’s picture

As the author of Wysiwyg Fields I will put in my 2 cents.

The reason that Insert can not currently provide something like this (and the reason that I chose not to use it with Wysiwyg Fields) is that it currently it renders all the available outputs (based on the chosen formatters) during the AHAH event that FileField uses for the file upload. There is no AHAH event to use for other fields so in no case can the output be generated.

In Wysiwyg Fields I approach it differently, which with a re-write (that I'd be completely open to helping with) Insert could also do, which is when the Insert button itself is clicked an AHAH event is fired which submits the form values back to Drupal which returns with the output data for the selected formatter.

Cheers,
Deciphered.

quicksketch’s picture

which is when the Insert button itself is clicked an AHAH event is fired which submits the form values back to Drupal which returns with the output data for the selected formatter.

Right, that's what my patch in #6 would do (but without the #ahah property I think, I just used normal jQuery). But ultimately I found this to be both an overly-complicated and slow approach. But you're right, it's the only way to make this possible. I'm happy WYSWIYG Fields exists because for most users, all they need is to insert an image or file. It's not a perfect solution, but at least it's a simple one that is easy to use.

deciphered’s picture

@quicksketch,

I do totally agree on the complexity, it was difficult, but I did manage to get it working to 99% of CCK fields. The only exception I know of at the moment is EMField, and that's because it doesn't define hook_elements.

While I agree with you that most only need FileField based inserts, I do think that the most important insert of all is a nodereference, because a nodereference with a Custom Formatter can be anything, it can be an ImageField that a user can update without breaking the link, it can be versioned FileField, it can be a dynamic quote, etc.

I would still be open to to discussing further with you to get the approach I took in Wysiwyg Fields into Insert, as you are more of an expert on the subject and it would benefit us both, but I 100% understand why you're opposed to the approach as it is rather tricky.

P.S. I really wish I knew about this issue and your patch before I started down my own path, could have saved me some potential grey hairs.

Cheers,
Deciphered.

lpalgarvio’s picture

i think the Media module will deprecate Insert.
it already does many things that Insert does, plus more stuff.

the way i see it, Media is the evolution of Embedded Media Field, with o FileField, ImageField, AudioField, VideoField, FileField Sources, Insert, WYSIWYG ImageField, IMCE, Styles, ImageCache and other modules mixed in.

that is, for Drupal 7.

in Drupal 6 we don't have Media and possibly will never have it.

WYSIWYG Fields deprecated WYSIWYG ImageField, which in turn does most of Insert does.

more collaboration please!

michaek’s picture

@LPCA I think this issue is perhaps the best argument for why Media isn't likely to deprecate this module. Rolling in support to insert the content of any CCK field doesn't seem like something that Media ought to support. I'm not speaking against collaboration - I think it's important to avoid duplicating features unnecessarily - but that this module's purview is potentially broader than Media's.

It does seem that wysiwyg_fields duplicates Insert philosophically, but that the authors are interested in collaborating. That seems like it'll benefit everyone!

I'll be checking out both modules in the near future, and I'll be happy to add some work to seeing this issue closed.

michaek’s picture

Actually, having looked at both Insert and wysiwyg_fields, I'm not convinced that either is the approach I would consider correct. Both seem to generate static HTML to be injected into the content, which seems like it introduces difficulties when the source for the inserted content changes (a file is uploaded to replace an existing file, for example). It seems better to me to use a placeholder and generate the appropriate content when the node is rendered, letting Drupal's cache mechanisms address performance concerns. I'm sure this has been dealt with elsewhere before, but I wanted to explain why I would not be likely to put work into closing this issue.

deciphered’s picture

michaek,

Wysiwyg Fields does not insert static HTML, it inserts a placeholder containing static HTML for the purpose of providing a preview in Wysiwyg mode, but the placeholder is converted into a Filter token on Save/Wysiwyg Detach, allowing the content to be updated if the formatter, field or other variable is changed.

Cheers,
Deciphered.

michaek’s picture

Thanks, @Deciphered. That sounds like an excellent approach, and I'll look at the source before I make any further conclusions. Sorry for the misunderstanding!

lpalgarvio’s picture

i sure hope some collaboration is in place so that some modules end up merged.

it would be awesome to have the equivalent to Fields, Views or Panels for WYSIWYG + Field insertion, gallery and management as a single complete light solution

paganwinter’s picture

subscribe

snater’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

With the D6 version not being supported any more and the last move on this ticket being seven years old, I am closing this issue. Anyway, this remains being a great idea for Insert and I am trying to implement that for the module's D8 version. But instead of raising this issue from the dead, I think it is more appropriate to have a new issue for D8: #2994066: Create interface for other modules.