WordPress.org

Forums

[resolved] How to disable wordpress Media Library Completely? (9 posts)

  1. Saqib
    Member
    Posted 2 years ago #

    Hello,

    I have a question please help. I have some experience with wordpress.

    I want to disable WordPress Media Library completely. What I am trying to say is I don't want wordpress to create ids for every image I upoad.

    Becuase as you know every media item can be accessed by using it's id I don't want that. I only want wordpress to upload images store them in uploads folder and make links to put inside the post.

    Example

    [caption id="attachment_170" align="aligncenter" width="300"]<a href="http://localhost/wp/wp-content/uploads/2012/01/screenshot.png"><img src="http://localhost/wp/wp-content/uploads/2012/01/screenshot.png" alt="123" width="300" height="225" class="size-full wp-image-170" /></a> 123[/caption]

    In this code I don't want wordpress to create [id="attachment_170"] or add it the the posts media library. Is there any way, any plugin to do that?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Can I ask why?

  3. Saqib
    Member
    Posted 2 years ago #

    I use single.php on my theme to show advertisements. So when the media item is accessed by it's url the ads show up too right next to the images which violates the google terms.

    Right now I use another website with wordpress to upload the images and them copy the upload code back to my site.

    Is there any way or plugin which just uploads the images and not attach them with posts and make uniques ids for them?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    If you upload images via the Media Library itself, there will be no Post or Page attachments. But images will still have unique ids. That part is pretty central to the way in which WordPress works.

  5. Saqib
    Member
    Posted 2 years ago #

    Okay thanks for the help. Please answer this question.

    If I want to redirect the attachment urls to the post url they are attached to, can I do that?

    Like this is the POST URL

    http://localhost/wp/earth-shes-a-beauty/

    and this is the Attachment URL

    http://localhost/wp/earth-shes-a-beauty/screenshot-2/

    can I redirect the Attachment URL to the POST URL automatically

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Not without getting into some fairly advanced coding.

  7. Saqib
    Member
    Posted 2 years ago #

    All right I guess I will just keep using the other website to add imgages. Thanks for the information.

  8. Saqib
    Member
    Posted 2 years ago #

    Hello please asnwer this one last question, can I delete stuff from Media Library without actually deleting the images from uploads folder. like running an sql query or something like that?

  9. Saqib
    Member
    Posted 2 years ago #

    Never mind I made it work. This code in functions.php redirects attachment pages back to the posts.

    <?php
    	function attachment_redirection() {
    	global $post;
    	if ( is_attachment() ) {
    	wp_redirect(get_permalink($post->post_parent));
    	}
    }
    	add_filter( 'wp_head', 'attachment_redirection' );
     ?>

    To only remove an object from attachment pages but show it on posts I used this

    <?php if ( is_single() && !is_attachment() ) : ?>
    	<div class=banner>Banner</div>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic