Insert images to post not working

Have you enabled debugging in wp-config.php change define(‘WP_DEBUG’, false); to define(‘WP_DEBUG’, true); This will cause WordPress and php to generate a lot more error messages. With very little detail to go on, my first guess would be file permissions on the upload directory on your server.

Customizing the 3.5 “Add Media” popup (Backbone.js)

I had do adapt Backbone for a project of mine, so I might help to get you started. If you want to adapt the rendering of your Backbone Templates, you need to rewrite them, because there are no built in filters for existing Templates. add_action(‘print_media_templates’, ‘print_my_media_templates’); function print_my_media_templates() { ?> <script type=”text/html” id=”my-custom-template”> //TODO: Copy … Read more

Filter by post category in Media Library

You can use pre_get_posts to filter the query. So you can retrieve a category from query vars the retrieve the post with that category set the media query to include only post having that posts as parent To give an UI you can use restrict_manage_posts hook to output a category dropdown. add_action(‘pre_get_posts’, ‘my_filter_media_by_cat’); add_action( ‘restrict_manage_posts’, … Read more

How to wp_upload_bits() to a sub-folder?

wp_upload_bits() uses wp_upload_dir() which fires the upload_dir filter allowing you to modify the upload directory’s path, sub-directory and URL. So you can use that filter to “force” wp_upload_bits() to use a custom path by doing something like: // Demo to get the image data. $url=”https://logo.clearbit.com/starcomww.com”; $content = file_get_contents( $url ); $_filter = true; // For … Read more

Can I use the wp media uploader for my own plugin?

You can use wp_enqueue_media() in your admin_enqueue_scripts hook. In a javascript file hook it into a button and use insert event to capture the selected image’s details $(‘.media-button’).click(function() { var media_uploader = wp.media({ frame: “post”, text : “Add image”, state: “insert”, multiple: false }); media_uploader.on(“insert”, function(){ var json = media_uploader.state().get(“selection”).first().toJSON(); var image_name = json.filename; var … Read more

Protecting direct access to PDF and ZIP unless user logged in (without plugin)

RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/([^/]*\.(pdf|zip))$ filecheck.php?file=$1 [QSA,L] This actually looks OK, except if you have additional subdirectories within the /uploads directory? An alternative is to include an additional condition on the original rule that only rewrites the request if the request ends in .pdf or .zip. For example: RewriteCond %{REQUEST_URI} \.(pdf|zip)$ [NC] RewriteCond %{REQUEST_FILENAME} -s … Read more