add insert button to fields, like in Insert

so we have the "insert" button in wysiwyg, which calls a new upload box, but we don't have one button on the fields

picking this code from Insert module could be doable.
does not deprecate the WYSIWYG button, just complements it

while not a huge hole in the module, it certainly is useful to have this feature. just imagine having the browse over 200 pictures when you can select the right file with a click...

http://drupal.org/node/1101964#comment-4400734

Comments

mstrelan’s picture

Subscribe

jenlampton’s picture

Title: add insert button to fields, like Insert module does - does not deprecate the WYSIWYG button, just complements it » Add support for insert module
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new827 bytes

Here's a patch that adds insert module support (against the 2.x branch)

edit: this works for file fields because that's what I needed it for, but it should be easy to extend for image fields as well.

tsvenson’s picture

Status: Needs review » Needs work
StatusFileSize
new32.39 KB

Great start, a couple of things though:

  • Requires the Insert module to work
  • Insert button is not visible until after you save and reopen the node in edit
  • Breaks the UI by placing the Insert dropdown and button above the image and Media buttons (see screenshot).
  • It inserts a hard link to the file, not the media placeholder

Insert module support for WYSIWYG

Especially the last point needs to be fixed. All files embedded using Media should use the placeholder markup so add-on modules can make full use of it.

Wouldn't it be possible to use code from the WYSIWYG plugin to accomplish this?

gagarine’s picture

Not a duplicate but a related issue than try to solve the same usability problem: #1062304: Fill in the available fields when creating media in the WYSIWYG

tsvenson’s picture

Title: Add support for insert module » Add Insert button to embed files in text areas (WYSIWYG)
Component: User interface » WYSIWYG integration

I don't think that the existing Insert module is the right way to go. Simply because it embeds a hard link to the file, not the placeholder code Media is using.

Not using the placeholder code would deviate from everything else and will be hard to deal with for sites when for example a file is deleted.

aaron’s picture

there's always sun's proposal for an #80170: Inline API.

aaron’s picture

tsvenson’s picture

@aaron: Ahh, like what I see there. If we can leverage Inline API it would be good.

dave reid’s picture

Odd that the insert form gets put 'above' the media widget fields which seems really odd. Otherwise this seems like a good workflow improvement for users of Insert module.

richsky’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, add-insert-suport-for-media-1140404-2.patch, failed testing.

Rob_Feature’s picture

I tried Jen's patch from #2 without success (7.x-2x-dev from June 14, 2012). After it didn't apply cleanly I manually applied it...no insert button appears that I can see (I also tried saving the node and reopening....without success)

lpalgarvio’s picture

i totally agree with tsvenson on #5
besides the link point,
insert places a config at the node type to allow image styles to use when picking a style at the node add/edit form. these allowed styles config has nothing in common with media own presets.
it's yet another module with similar/duplicated code

but i do like the output in the node add/edit form that insert achieves.

also as side note, i do think insert's allowed styles config (styles per field per node type) is beneficial and media module could leverage that and add a similar behaviour some time in the future (another issue).

mrfelton’s picture

There is a sandbox project Media Insert that attempts to do this. Though. not really working for me.

richsky’s picture

My opinion on this is that Media is a nicer way to deal with media in general and the image button in wysiwyg is crap. I used this patch with 7.x-2.0-unstable5 and it was working quite well...

gmclelland’s picture

Note: there is the issue #1664418: Replace custom WYSIWYG integration and support WYSIWYG Fields module instead. Which could probably replace this functionality with the WYSIWYG Fields module. I never used it, but I think the general idea is that you would create a field for media and WYSIWYG Fields module would provide the WYSIWYG button to insert the media.

richsky’s picture

Well noted, but for me this patch was closer to give me an exploitable result than these Wysiwyg field integrations (that are nevertheless interesting), and seems to involve too many other modules.
My point is that I don't want to let users embed links or placeholder code to media not attached to the node.
A flexible way could be a media field that allow placeholder code insertion in textarea or/and (on config choice and based on module presence). Insert does it quite well for the direct insertion, imagine you don't allow editor or it can't be loaded (in panels editing), but could be improved, and a Wysiwyg button that use media for placeholder code insertion, but using it should automatically add the selected media to the node media field and should substract on delete.
See http://drupal.org/node/1062304#comment-5465854

quicksketch’s picture

Just a note in response to @tsvenson in #3:

All files embedded using Media should use the placeholder markup so add-on modules can make full use of it.

Insert module is absolutely, in no way, limited to outputting hard links. Every module is allowed to create *whatever* markup they like. I've had users in the past override the templates to use both Inline module and BBCode instead of HTML for example. You're given access to the entire $file object (and the Field $widget) to generate whatever output you desire to insert, it just so happens that all the default implementations generate plain HTML.

quicksketch’s picture

Though let me backtrack a little bit from that statement, while this is true you would need to make your own Insert styles (the things that get inserted into the textarea/WYSIWYG). And unfortunately there's no way to limit image styles to a particular widget, so you'd probably end up with all of Insert's normal styles plus a bunch of styles that specifically work with Media.

gghh2’s picture

#15 Posted by richsky on August 14, 2012 at 1:04pm
My opinion on this is that Media is a nicer way to deal with media in general and the image button in wysiwyg is crap. I used this patch with 7.x-2.0-unstable5 and it was working quite well...

I don't understand how you can apply this patch because all line numbers are different... Can you explain how you apply it ?

wulff’s picture

StatusFileSize
new61.54 KB
new2.8 KB

I need Insert-like functionality for a site I'm building, and I've created the attached patch which seems to do the trick for me.

It adds a "Insert media" button to each media item in the node edit form. Clicking the button inserts a Media Filter macro at the current cursor position in the body textarea. (I only need it to work with a plain textarea, so there's no wysiwyg support.)

The patch is based on code from sreynens sandbox project and the Insert module (and it doesn't depend on the Insert module).

This is just scratching my own itch, but it seems like other people have been looking for this functionality as well.

screenshot

wulff’s picture

StatusFileSize
new2.79 KB

Fixed indentation issue in patch.

gmclelland’s picture

That looks interesting, but how does a user choose the media style to insert?

wulff’s picture

Currently, they don't :P

This simple patch doesn't support any kind of configuration. It was created to satisfy a single use case: insert media using a specific view_mode and specific classes for the resulting markup.

gooddesignusa’s picture

I'm trying to use the latest patch from #22 but the insert option doesn't seem to show up while editing the field.
It looks like it has something to do with the insert function insert_widgets on line 118 of the insert.module
It seems to expect a function media_insert_widgets before it will render that option on the field settings page.
The patch from #2 use to work but no longer applies. Any tips will be greatly appreciated. Thanks in advance.

edit: ignore my post above. The latest patch has nothing to do with the insert module.

drupa11y’s picture

Any updates on this?

drupa11y’s picture

Couldn´t this feature be realized by media supporting file field sources?
Then the current modules could be used.

There´s an issue for this here: https://drupal.org/node/1139642

kovacsaba’s picture

Title: Add Insert button to embed files in text areas (WYSIWYG) » Sandbox project

I had similar problem with Media and Insert modules, so i wrote a small module to integrate them. I mention that this module only works with Media 7.x-1.x version.

https://drupal.org/node/2088363/git-instructions/7.x-1.x

devin carlson’s picture

Title: Sandbox project » Add insert module integration
Status: Needs work » Fixed

I'd suggest provided Insert integration in a separate module as is done in the sandbox project referenced in #28.

Status: Fixed » Closed (fixed)

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

alan d.’s picture

Issue summary: View changes
Status: Closed (fixed) » Closed (won't fix)

It looks like either both related modules are either broken or targeted to a specific version or simply just near impossible to setup.

The other project is: https://drupal.org/project/insert_video that supports images too (apparently).

Anyone had any luck with these?

@Devin Carlson
Are you sure that combining this into Media is not an option?

marcvangend’s picture

Alan D.: In that case, this should be "needs work", right?

alan d.’s picture

I was hoping that was the status what one of the maintainers was going to decide on. I didn't want to force their hands :)

Re. status, it was never "fixed" here, rather it was deferred to the other module(s), so "Closed (won't fix)" was the right status imho. Some maintainers use "Closed (works as designed)" when deciding not to implement a feature, although that normally this refers to a feature / limitation that was perceived as a bug.

https://drupal.org/node/156119

rainbowarray’s picture

Component: WYSIWYG integration » Code

Just wanted to add that I found an alternative that worked for me. It's a bit clunky, but it works.

You can use Advanced Entity Token (https://drupal.org/project/aet) to put a token for a media field into a body field with WYSIWYG. This worked far better for me than WYSIWYG Fields because I wanted to have the Media file selector widget on the node edit form, so content contributors could use that to update a file without having to mess with the WYSIWYG buttons, which can get a little clunky.

My use case was that I wanted to combine individual items in a media field with some HTML, and this will do the trick. I'm not using AET Insert, because that interface was pretty wonky. So I have to manually enter the filter text to get this to do what I want to do. Not glamorous, not something I'd want content editors to do, but hey, it works!

maxplus’s picture

Hi,

I'm working with sandbox from #28 in combination with 7.x-2.x version and it works for me until now.

Thanks!