GithubHelp home page GithubHelp logo

thomasgriffin / new-media-image-uploader Goto Github PK

View Code? Open in Web Editor NEW
173.0 173.0 31.0 156 KB

This plugin provides a solid example for integrating the new media manager workflow into your plugins/themes by showing you how to upload/insert an image file into a text field.

JavaScript 57.84% PHP 42.16%

new-media-image-uploader's Introduction

Hello! ๐Ÿ‘‹

Iโ€™m a tech entrepreneur, veteran business owner, seasoned investor and a leader of leaders. Combined, my software powers organizational success for more than 25 million websites across the world.

You can find me writing at about leadership (and the occassional WordPress tutorial) at https://thomasgriffin.com. ๐Ÿš€

new-media-image-uploader's People

Contributors

thomasgriffin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

new-media-image-uploader's Issues

Great job

This is not an issue. Just wanted to say how well you have put this together. Very easy to follow and implement in projects.

Adding support for multiple fields.

Let's say we have a custom metabox. Where we have only one button "Upload media".
Is there a posibility after selecting more then one images to create the html with something like attachment.each() ?

I'm trying to do this but did't found a way yet.

Best Regards.
Anghel Gabriel

EDIT:
Nevermind i found i way.

How to control whether or not an upload is attached to the current post?

Thanks for the great starting point. I'm having trouble deciphering a few options for wp.media. Is there a way to control whether or not files uploaded through the dialog are attached to the current post or not?

Previously I was adding (or not adding) a post_id query string parameter to the media iframe URL. Now, I'm not sure. Is this possible?

On a related note, what about restricting the files listed (or not) to files attached to the current post?

Button customization

Thank you very much for this! Solved a few questions for me. :-)

* We can also determine whether or not the modal requires a selection
* before the button is enabled. It requires a selection by default,
* and since this is the experience desired, let's keep it that way.

Really had to laugh about that, because you don't say HOW you can set this option. I tried selectionRequired = false and required = false. Can't imagine any other variable names...

I wonder why there is no complete documentation of wp.media, it costs so much time to figure out how to set which option. :-(

multiple selection without shift

Also, not a bug, but still kind of an issue. Is there a way to allow for multiple selections without the need to press shift? (Just like when creating a "gallery" in the new uploader). For me it makes more sense, when allowing multiple images in the first place, to make it as easy as possible for users, thus not require a special key to really select multiple images. Any advice much appreciated.

library type?

hi thomas, another question.
in media.js there's

library: {
    type: 'image'
},

is there a list of available type?
how to add more than one library type?
how about file extension? for example i just want to list zip file?
can i also have more than one file ext? for example zip and pdf?

thank you

Multiple managers in one page

I have a problem with having multiple media managers in my plugin's admin panel: the link of the image goes only to the first input having the id "tgm-new-media-image".

How exactly can I make those to have their own specific id's as in 'id = "tgm-new-media-image[row_id]" '? Or is there another solution to this problem? I've tried a bunch of stuff, but nothing seems to work.

EDIT
Nevermind, got it to work! If anyone is experiencing the same problem, just use the data-attribute in the link to get the right id for the text input.

Default Tab on modal opening

Hi Thomas,

I have been pulling my hair out over this one for some time now. I thought I just ask here.
I am opening a 'select' frame, so it shows two tabs at the top: "Upload Files" & "Media Library". Is there a way to make the default tab the "Upload Files" tab?

So basically every time that particular media frame opens, it will start on the "Upload Files" tab.
Thanks for any ideas,
Sascha

How to send to input if using frame: 'post' ?

hi thomas,
thank you for this. awesome job.
btw, if using frame:'post' how can i send the url of the image to input field?

i try this but it didn't work:

tgm_media_frame.on('post', function(){
    // Grab our attachment selection and construct a JSON representation of the model.
    var media_attachment = tgm_media_frame.state().get('selection').first().toJSON();

    // Send the attachment URL to our custom input field via jQuery.
    $('#tgm-new-media-image').val(media_attachment.url);
});

thank you.

destination folder

Hi Thomas

thanks for this code sample. I'm wondering if it's possible to define the destination folder, maybe a subfolder of the default uploads folder?
thanks

Gallery support

Is there a way to make this support wordpress galleries so I can create galleries instead of a single image?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.