Importing WordPress Attachments Into Custom Directories In wp-content/uploads/

Yes you can by programatically adding the attachment. $upl = wp_upload_dir(); $target = $upl[‘basedir’] . ‘/YOUR_CUSTOM_FOLDERS/YOUR_FILE’; $filetype = wp_check_filetype($target); $attachment = array( ‘post_mime_type’ => $filetype[‘type’], ‘post_title’ => $YOUR_FILE_TITLE, ‘post_content’ => ”, ‘post_status’ => ‘inherit’ ); wp_insert_attachment( $attachment, $target, $POST_ID_TO_ATTACH_TO ); This will tell WordPress that there is an attachment at $target and you can optionally … Read more

How can I upload SVG images using the media uploader?

You need to filter the allowed upload file types and add the SVG filetype to the list: function allow_svg_upload_mimes( $mimes ) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; } add_filter( ‘upload_mimes’, ‘allow_svg_upload_mimes’ ); Also on GitHub

Extend 3.5 media uploader plugin to change button name

Figured it out using a different method. Help from here. $.fn.oeUpload = function(options) { // Set default options var defaults = { ‘preview’ : ‘.preview-upload’, ‘text’ : ‘.text-upload’, ‘button’ : ‘.button-upload’, ‘name’ : ‘Choose Image’ }; var options = $.extend(defaults, options); var uploader; $(options.button).click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen … Read more

Modify the array of selected images in media modal

I’m able to do the following in media modal: var selection = wp.media.frame.state().get(‘selection’); // get selected collection attachment = wp.media.attachment(id); // get attachment with id attachment.fetch(); selection.add(attachment); // add attachment to selection collection There should be .remove() method or something similar.

Ignore a filter on the media library

You can use is_admin() in conjunction with the admin global variable $pagenow to make sure you’re not on either the upload or media page: function remove_images( $where ) { global $wpdb, $pagenow; if( is_admin() && in_array( $pagenow, array( ‘upload.php’, ‘media-upload.php’ ) ) { return $where } $where .= ” AND {$wpdb->posts}.post_mime_type NOT LIKE ‘image/%'”; return … Read more

How to add a category or tag to media at upload time with the browser uploader?

I’ve been using Media Tags plugin with much success – it was very useful for retrieving images belonging to certain page with specific tags with following code: $results = get_attachments_by_media_tags(array(“media_tags”=>”gallery”, “post_parent” => $global_id, “order” => “ASC”)); Of course you can easily tag anything that sits in your media library (I wasn’t even aware that you … Read more

front end post with multiple upload images?

the multiple=”multiple” or multiple=”” attribute of input file tag is fairly new and not widely supported cross browser but if that is the way you want to go, try this: <form … <input type=”file” id=”image” name=”image[]” onchange=”updateList();” multiple=”multiple” > <ul id=”file_list”></ul> </form> <script> function updateList(){ //get the input and UL list var input = document.getElementById(‘image’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)