WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Customize Media Manager (5 posts)

  1. mirrera
    Member
    Posted 1 year ago #

    I have looked far and wide, and tried numerous plugins but can not find a simple way to offer my beginner users a way to simply upload a picture, no galleries, no video, no library of other people's photos. Just upload, see it in the editor and move on. I can take care of the size and placement in the style sheet.

    I have tried hiding the media buttons and using the SBUploader plugin with some custom meta boxes. The SBUploader gives no control over placement it just puts the image below the text. So I added custom meta boxes with editors for text below each post. The problem is that the uploaded images do not show in the editor, so my users will be confused.Plus I feel like I am inventing a square wheel.

    I went back to turning on the Media Manager and found a way to unset the gallery, and url tag but then it defaults to a very confusing screen, since the media manager defaults to library view instead of upload. I am so stunned that with the upgrade and people all over the web asking for a way to customize media management that I can't find an alternative Media Manager.

    Can someone point me to either a simple plugin for uploading images and having them show in the editor, without any other features? Or a way to hook into the current media manager and have it open to the upload screen, insert into post, and nothing else. I would love the ability to have a user see a library of the images that they have uploaded, but that may be too much. I would be happy to pay for a plugin like that!

  2. Marcel Brinkkemper
    Member
    Posted 1 year ago #

    Have you tried to use a filter for 'media_view_strings'?
    I have made a similar uploader like you need with a filter like this:

    function my_view_strings( $strings) {
      // disable some views
      $disabled = array( 'selectFiles', 'createNewGallery', insertFromUrlTitle', 'createGalleryTitle' );
      foreach( $disabled as $string )
        $strings[$string] = '';
      $strings['allMediaItems'] = __( 'Select a view', 'eazyest-gallery' );
      $strings['insertIntoPost']     = __( 'Done uploading', 'eazyest-gallery' );
      return $strings;
    }
    add_filter( 'media_view_strings', 'my_view_strings' );

    and add this in a style element to hide the buttons:

    .button.button-large.media-button-gallery {
      height: 0;
      padding: 0;
    }
    .media-menu-item:empty {
      display: none;
    }

    hope this helps

  3. mirrera
    Member
    Posted 1 year ago #

    Hi,
    Yes Thank you! I did do that at first, but I could not get the simplicity that I wanted because I could not get my CSS to over-ride the media template even with !important, then I found a filter that made it possible to add styles (thanks to: brasofilo: http://wordpress.stackexchange.com/questions/75746/how-to-add-custom-css-to-the-media-thickbox). From that point on it was FUN. I ended up unsetting the media library tab, styling away everything except the uploader. I also styled away the edit button in the editor window and put it all in a plugin for a simple uploader. Then I made another plugin for removing all links around images. Then I styled all the different alignment possibilities to be what I want them to be in my normal stylesheet.

    Here is what I used for the uploader plugin (I am sure there are extra styles, but it was late and it works) It can also just go in the functions.php for anyone else that does not want to have a plugin:

    //Get rid of media library tab
    add_filter( 'media_view_strings', 'custom_media_uploader' );
    function custom_media_uploader( $strings ) {
    	unset( $strings['mediaLibraryTitle'] ); //Media Library
    	 return $strings;
    }
    //Add new styles to get rid of what I don't want and to make it pretty
    add_action( 'print_media_templates', 'my_simple_uploader' );
    function my_simple_uploader()
    {
        ?>
        <!--Style away the side menu, the media library browser, re-design what is left-->
        <style>
        	.media-menu,.attachments-browser,.media-frame-menu,#wp_editimgbtn,.media-router .active:after {
                display:none;
            }
    		.media-modal{
    			width:600px;
    			max-height:400px;
    			margin:auto;
    		}
    		.media-frame-title h1{
    			font-family:"gill sans";
    		}
    		.media-frame-title,.media-frame-router,.media-frame-toolbar{
    			left:0px;
    			text-align:center;
    		}
    		.media-frame-content,.uploader-inline-content{
    			margin-top:40px;
    			position:static;
    			text-align:center;
    		}
    		.media-toolbar,.media-toolbar-primary{
    			position:static;
    			width:128px;
    			padding:0px;
    			margin:auto;
    			float:none;
    			text-align:center;
    		}
    		media-button-insert{
    			display:block;
    		}
    		.media-router{
    			float:none;
    			width:100px;
    			margin:auto;
    		}
    		.media-router a{
    			border-right:0px;
    		}
        </style>
        <?php
    }

    Here is the filter for removing link tags around all images before they go to the browser. Even old ones which is great because I was re-designing a blog with old posts. I tried a number of filters with regex but this one worked for me, and I am happy not to have to write my own preg_replace (thanks to: krembo99: http://stackoverflow.com/questions/11282580/how-to-remove-hyperlink-of-images-in-wordpress-post ). (Note; this works in the functions.php but I made a separate plugin for it.) Here is the code:

    add_filter( 'the_content', 'remove_image_link' );
    function remove_image_link( $content ) {
        $content =
            preg_replace(array('{<a[^>]*><img}','{/></a>}'), array('<img','/>'), $content);
        return $content;
    }
  4. Marcel Brinkkemper
    Member
    Posted 1 year ago #

    This works great,
    Now I only need a way to distinguish between Add Media and Set featured image.

  5. mirrera
    Member
    Posted 1 year ago #

    I was lucky, I did not need featured image capability. I am sure that would be very useful (and challenging!). I would be interested to see what you come up with.

    I am surprised —with all the work that went into the Media Manager— that the developers have not come up with a back-end way to turn on and off every possible feature. Like the Adminize plugin does for the admin screens. I think it should be a core feature.

Topic Closed

This topic has been closed to new replies.

About this Topic