Get upload URL by blog ID in multisite
Why not just use get_option(‘upload_path’) after your switch_to_blog( $blog_ID );? Does that do it?
Why not just use get_option(‘upload_path’) after your switch_to_blog( $blog_ID );? Does that do it?
Custom collection in media manager?
To add the taxonmies from post type post, the default, then it is easy to add taxonmies ‘category’ and ‘tags’ with a small plugin liek the source below. <?php /** * Plugin Name: Attachment Taxonomies * Plugin URI: * Text Domain: attachment_taxonomies * Domain Path: /languages * Description: * Version: 1.0.0 * Author: Frank Bültge … Read more
You can checkout this link https://codex.wordpress.org/Javascript_Reference/wp.media jQuery(function($){ // Set all variables to be used in scope var frame, metaBox = $(‘#meta-box-id.postbox’), // Your meta box id here addImgLink = metaBox.find(‘.upload-custom-img’), delImgLink = metaBox.find( ‘.delete-custom-img’), imgContainer = metaBox.find( ‘.custom-img-container’), imgIdInput = metaBox.find( ‘.custom-img-id’ ); // ADD IMAGE LINK addImgLink.on( ‘click’, function( event ){ event.preventDefault(); // If … Read more
I’m hereby answering my own question, because i found a solution, but I’m really interested in your opinions towards it. Or maybe you have a much better solution, if so, I really would like to here about it. Research result My research results were: 1. get the files outside of the document root, www folder; … Read more
If you are talking about the answer i posted here its simply uploading file in an iframe to achieve “Ajax like” submit. Now if you already have a form that handles the post submit you can simply add the upload file field input somewhere in your form: <form … … <input type=”file” name=”thumbnail” id=”thumbnail”> … … Read more
I would strongly advise against using $post->guid – WordPress now generates them in the form; http:/example.com/?attachment_id=ID Use the same method that many of the attachment-related functions use; $filename = basename ( get_attached_file( $data->ID ) );
This will allow you to rename an attachment as soon as its uploaded: add_action(‘add_attachment’, ‘rename_attachment’); function rename_attachment($post_ID){ $file = get_attached_file($post_ID); $path = pathinfo($file); //dirname = File Path //basename = Filename.Extension //extension = Extension //filename = Filename $newfilename = “NEW FILE NAME HERE”; $newfile = $path[‘dirname’].”https://wordpress.stackexchange.com/”.$newfilename.”.”.$path[‘extension’]; rename($file, $newfile); update_attached_file( $post_ID, $newfile ); }
If you want display an image that is inserted into your content (a hotlinked image, for example), you must use a function like this (source): add in functions.php: function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img … Read more
There is a Plugin called Attachments http://wordpress.org/extend/plugins/attachments/ Maybe this is something you looking for.