Closed tw2113 closed 10 years ago
Yep,we need todo this.
+1
WP core does this for setting the text on the custom background image:
// Create the media frame.
frame = wp.media.frames.customBackground = wp.media({
// Set the title of the modal.
title: $el.data('choose'),
// Tell the modal to show only images.
library: {
type: 'image'
},
// Customize the submit button.
button: {
// Set the text of the button.
text: $el.data('update'),
// Tell the button not to close the modal, since we're
// going to refresh the page when the image is selected.
close: false
}
});
Ok, after some research, the problem actually lies in the frame: 'post',
that we use in the JS. There are two formats of inserting media:
post
: Contains the sidebar for Inserting Media that S3 Hooks into
and select
which allows us to pass in parameters for setting the 'Insert' and Title.
The reason we can't hook the post
is that the output generated, including the button is actually part of the callback for the default insert media views. Where as with the select
view, there is no need to generate a view, it's built into that modal.
If we change to a select
we'll actually break the S3 extension in a bad way, in that the toolbar to display it's settings won't even be visible. I say for now we stick to just the Insert into download
until we can come up with a solution that won't break S3, or we can manage to determine how to extend the Select
view to allow a toolbar.
Makes you wish they i18n'd this spot, doesn't it?
@tw2113 Yeah, it's like psudo i18n'd allowing us to filter it out, but i think the main issue actually lies in the way that the media.view.MediaFrame.Post
is built as opposed to how meida.view.MediaFrame.Select
is built.
In the end this will work, and achieve the goal at hand, but with there was a bit more flexibility in this without going off the deep end.
Do you know if it is possible to create a custom post
frame, similar to media.view.MediaFrame.Post
?
Every time I try and alter the post
MediaFrame I lose the primary loads. I think we'd have to rewrite it completely, and I'm not even sure it'd work.
@pippinsplugins Where do we stand on this? Are we going to keep investigating somehow rebuilding the post
view to reflect the changes we want? We can't use the standard post
without breaking the S3 Extension.
We can use this filter to at least alter the current Insert
view. Thoughts?
Let's just go with your original method for now.
Works great @cklosowski
When adding a file to a download, the media modal pops up like expected, however the button in the lower right still says "Insert into post". For UX and consistency, perhaps consider changing to "Insert into download" for your post types.
Just a thought, nothing critical.