Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a way I can allow the user to attach images as attachments to a post without allowing him to insert them within the text itself? Ideally the Upload Media button remains the same but the image is not inserted within the text.

The reason is I don't want users to start creating their own layouts and I want the template to always be consistent.

(I know there is a quick hack to just strip out tags in the content pages from the theme itself but that will just confuse my users, so I need a way to just attach images).

share|improve this question
    
You could hook in on pre_save_post and strip those tags, but I think you're better off simply disabling all unwanted TinyMCE buttons. –  kaiser Oct 10 '12 at 21:57
    
Stripping tags won't do because it will confuse users. They will start putting the images in and complaining that they're not appearing where they put them. I can disable TinyMCE buttons but the Upload/Insert dialog still has the button 'Insert into Post', so its not quite a solution either. –  jbx Oct 10 '12 at 23:44
add comment

2 Answers

up vote 1 down vote accepted

One way to do this would be to simply hide the upload/insert media button: and, then add featured image support for your themes posts, so a user can still attach images to the post.

Hide upload/insert media button for your theme in: functions.php:

function hideUploadInsert($hook)
{
    if($hook != 'post.php' AND $hook != 'post-new.php')
        return; // if not in the edit or new admin pages, for Posts or Pages, then do nothing.
    echo '<style type="text/css" media="screen">
        #wp-content-media-buttons {
            display: none;
        }
</style>';
}
add_action('admin_enqueue_scripts', 'hideUploadInsert');

Add featured image support to your themes posts in: functions.php

add_theme_support('post-thumbnails', array( 'post' ));


EDIT:

I didn't realize you were referring to attaching multiple images to a post. You could just use the css I gave above to hide the button for inserting images into a post: and, then use one of the plugins that come up in a google search for attaching multiple featured images to a post: https://www.google.ca/search?q=wordpress+multiple+featured+images

share|improve this answer
    
Thanks for your answer. Can you explain a bit more the featured image part? By default on my installation posts can already have a featured image. It is used for the thumbnails on the index page. However I need multiple image attachments to the post not one. –  jbx Oct 10 '12 at 23:41
    
Ahhh. Please see my updated answer. –  Ben Oct 10 '12 at 23:51
    
Thanks. Actually I was thinking of combining your answer together with this plugin wordpress.org/extend/plugins/attachments so that I keep the featured image (which seems to be intended more for the thumbnail in the index page) separate. –  jbx Oct 10 '12 at 23:56
    
Are you sure the file to edit is style.css in my theme? It doesn't seem to work that way and when I inspect the page it doesn't seem that it is loading style.css from my theme in the admin pages. –  jbx Oct 11 '12 at 0:02
    
LOL sorry, that was a total "Doh!" moment for me. You cannot style the admin area from your themes style.css file. Please see the top code area of my further updated answer for how to do this. –  Ben Oct 11 '12 at 0:30
show 3 more comments

Maybe the following works:

add_filter( 'type_url_form_media', '__return_null' );

Anyway: The function is already deprecated and the whole UI will likely be reworked with 3.5 or 3.6, so this solution might not work for too long.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.