Forums

[resolved] Removing options in upload table (20 posts)

  1. Alyson
    Member
    Posted 3 years ago #

    i need remove this options when i try upload a image

    http://img183.imageshack.us/img183/3070/imagemro0.jpg

    align

    show

    caption

    And your options.
    Everythinq.

    I try search in the code, but nothinq found in includes/media.php
    And to confuse much more, don´t have a translation to pt-br

  2. mores
    Member
    Posted 3 years ago #

    that'll probably only work when you edit a core WordPress file like media.php or upload.php or something.
    Not advisable. Just inform your client to ignore the options.

  3. Alyson
    Member
    Posted 3 years ago #

    My cliente want to remove this options for registred users :(

    Yes i try search in any archive , media.php, upload.php and much more and nothinq....

    thanks for your help =/

  4. schoe
    Member
    Posted 3 years ago #

    To remove the first two option lines you can add the following lines to the functions.php of your theme (or to another plugin you have installed):

    function ms_attachment_fields_to_edit($form_fields, $post) {
        if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    	// align: (radio)
    	$form_fields['align']['value'] = 'aligncenter';
    	$form_fields['align']['input'] = 'hidden';
    
    	// image-size: (radio)
    	$form_fields['image-size']['value'] = 'thumbnail';
    	$form_fields['image-size']['input'] = 'hidden';
        }
        return $form_fields;
    }
    add_filter('attachment_fields_to_edit', 'ms_attachment_fields_to_edit', 11, 2);

    The third option line seems to be inserted by another plugin you are using. To remove it, search for
    <input type="radio" ...>
    in its php-files and add the corresponding lines to the above function.

    Works for me at least :-)

    Michael

  5. Alyson
    Member
    Posted 3 years ago #

    ok shoe, i will test and do feedback.

    Thanks so much :D

  6. Alyson
    Member
    Posted 3 years ago #

    i try injet this function in functions.php of my template

    and i get this error:

    Warning: Cannot modify header information - headers already sent by (output started at /themes/Aspire/functions.php:19) in /blog/wp-includes/pluggable.php on line 770

    and i try in functions.php of wp-includes

    and:

    Fatal error: Call to undefined function add_filter() in /blog/wp-includes/functions.php on line 2339

  7. schoe
    Member
    Posted 3 years ago #

    Hi rn2web

    I'm not a professionel but as far as I know

    • you should better not try to hack WP. Changing anything in wp-admin or in wp-includes is a hack!
    • If you place it in your themes functions.php you might also need one or both of the following lines:
      include_once('wp-config.php');
      include_once('wp-includes/wp-db.php');
    • It should work without errors if you put it in a standard plugin. Perhaps you could try to put it in the example plugin hello.php in "wp-content/plugins/".
      ... and then activate it - of course!

    good luck!

    Michael

  8. schoe
    Member
    Posted 3 years ago #

    ... in addition to my last message:

    I definitly know that it works in WP 2.6 if you place the code in the nice little upload plugin "photojar-base"!

    Michael

  9. Alyson
    Member
    Posted 3 years ago #

    hi michael

    I hack almost all my wordpress 2.6 , lol
    Is because my client need a personal version for your project, but ok.
    Is everythinq perfect at this moment.
    About this little problem, is last problem to finish my work ^_^

    --------------------------
    The plugin i am using is to do resize big images and do a thumbnail.
    Your name: flexible-upload

    --------------------------

    I will try do your new instructions

    ( yes, my english is very poor )

  10. schoe
    Member
    Posted 3 years ago #

    I also tried flexible-upload.

    For my needs WP 2.6 + photojar has the same functionality
    ... and is much easier to change/hack!

  11. Alyson
    Member
    Posted 3 years ago #

    I am confused, look like is my themes functions.php

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebars(2, array(
            'before_widget' => '<div id="%1$s" class="sb-bot"><div class="sb-top"><div class="sb-right"><div class="sb-left"><div class="sb-rb"><div class="sb-lb"><div class="sb-rt"><div class="sb-lt">',
            'after_widget' => '</div></div></div></div></div></div></div></div>',
            'before_title' => '<h2>',
            'after_title' => '</h2>',
        ));
    ?>
    <?php function widget_search() {
    ?><?php
    }
    if ( function_exists('register_sidebar_widget') )
        register_sidebar_widget(__('Search'), 'widget_search');
    
    ?>

    I need add this lines correct?

    <?php
    
    function ms_attachment_fields_to_edit($form_fields, $post) {
        if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    	// align: (radio)
    	$form_fields['align']['value'] = 'aligncenter';
    	$form_fields['align']['input'] = 'hidden';
    
    	// image-size: (radio)
    	$form_fields['image-size']['value'] = 'thumbnail';
    	$form_fields['image-size']['input'] = 'hidden';
        }
        return $form_fields;
    }
    add_filter('attachment_fields_to_edit', 'ms_attachment_fields_to_edit', 11, 2);
    
    ?>

    And:

    <?php
    
    include_once('wp-config.php');
    include_once('wp-includes/wp-db.php');
    ?>

    But i get a lot of erros.
    I am trying resolve the 2 first lines.

    No, i don´t modify the plugin flexive-upload yet with your instructions

    I will try use photojar with your instructions.

  12. schoe
    Member
    Posted 3 years ago #

    Hi there

    I just tested my function putting it in my themes functions.php

    It works perfect together with photojar-base plugin.
    And you don't even need the two include_once statements!

    If you still have problems, disable all of your other plugins - just for a test - write a post and upload an image.

    • There should be no errors.
    • And the two option button lines are gone!

    Michael

  13. Alyson
    Member
    Posted 3 years ago #

    I thank you so much for your help michael, but not working for me, a lot of erros and conflict with outhers modifications :(

    You do not know where these menus in php files?

    align

    show

    http://img165.imageshack.us/img165/7515/menusfu9.jpg

    I am search in all wp-admin files and nothinq :(
    Yes, hack this menu is only way to me :(

    obs: this language is portuguese
    miniatura = thunbnail
    tamanho original = full size

  14. Alyson
    Member
    Posted 3 years ago #

    i found somethinq in wp-includes/js/tinymce/langs/wp-langs.php

    I try remove:

    contextmenu:{
    align:"' . mce_escape( __('Alignment') ) . '",
    left:"' . mce_escape( __('Left') ) . '",
    center:"' . mce_escape( __('Center') ) . '",
    right:"' . mce_escape( __('Right') ) . '",
    full:"' . mce_escape( __('Full') ) . '"
    },
    size:"' . mce_escape( __('Size') ) . '",

    Nothinq happen...

    Copying the code to html editor i get:

    <table cellspacing="0" cellpadding="0">
      <tr>
        <th scope="row" valign="top"><label for="attachments[11][align]">Alinhamento <br />
        </label></th>
        <td><input name="attachments[11][align]" id="image-align-none-11" value="none" checked="checked" type="radio">
            <label for="image-align-none-11">Nenhuma</label>
            <input name="attachments[11][align]" id="image-align-left-11" value="left" type="radio">
            <label for="image-align-left-11">Esquerda</label>
            <input name="attachments[11][align]" id="image-align-center-11" value="center" type="radio">
            <label for="image-align-center-11">Centro</label>
            <input name="attachments[11][align]" id="image-align-right-11" value="right" type="radio">
            <label for="image-align-right-11">Direita</label>
        </td>
      </tr>
      <tr>
        <th scope="row" valign="top"><label for="attachments[11][image-size]">Tamanho <br />
        </label></th>
        <td><input name="attachments[11][image-size]" id="image-size-thumb-11" value="thumbnail" type="radio">
            <label for="image-size-thumb-11">Miniatura</label>
            <input name="attachments[11][image-size]" id="image-size-medium-11" value="medium" checked="checked" type="radio">
            <label for="image-size-medium-11">Médio</label>
            <input name="attachments[11][image-size]" id="image-size-full-11" value="full" type="radio">
            <label for="image-size-full-11">Tamanho original</label></td>
      </tr>
    </table>
  15. schoe
    Member
    Posted 3 years ago #

    You can change almost everything in WP using filter and action hooks provided that you don't hack anything in WP.
    All your changes should be located in the wp-content folder (themes or plugins).

    If you start hacking WP you will very likely get lots of error messages by the safety management of WP.

    Most of the lines you want to hack are in wp-admin/includes/media.php (1302-1314 and many others ...) but it's the wrong place to really change the output !!!

    My plugin function can only work if you have a clean (unhacked) WP-Installation.

    If you go on hacking I can't help you.

    Michael

  16. Alyson
    Member
    Posted 3 years ago #

    :(

  17. schoe
    Member
    Posted 3 years ago #

    ... but it's your chance:

    • If you update WP you would have to do all the hacks again ... and then they would be in other places ...
    • If you use action and filter hooks you can update any time ... your changes will be OK!!!
    • ... and you can use other plugins (functions) with no errors !

    Why not give it a try :)
    WP Plugin API

    Michael

  18. Alyson
    Member
    Posted 3 years ago #

    WOW!

    i got it!!!!!!

    thanks a lot!

    I put your code in my wp-admin/includes/media.php
    In first line and all right now!

  19. Alyson
    Member
    Posted 3 years ago #

    my final code:

    <?php
    
    function ms_attachment_fields_to_edit($form_fields, $post) {
        if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    
    	// align: (radio)
    	$form_fields['align']['value'] = 'aligncenter';
    	$form_fields['align']['input'] = 'hidden';
    
    	// image-size: (radio)
    	$form_fields['image-size']['value'] = 'thumbnail';
    	$form_fields['image-size']['input'] = 'hidden';
    
    	// Caption: (radio)
    	$form_fields['image-caption']['value'] = 'caption';
    	$form_fields['image-caption']['input'] = 'hidden';
    
        }
        return $form_fields;
    }
    add_filter('attachment_fields_to_edit', 'ms_attachment_fields_to_edit', 11, 2);
    
    ?>

    :)

  20. Alyson
    Member
    Posted 3 years ago #

    my final code:

    <?php
    
    function ms_attachment_fields_to_edit($form_fields, $post) {
        if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    
    	// align: (radio)
    	$form_fields['align']['value'] = 'aligncenter';
    	$form_fields['align']['input'] = 'hidden';
    
    	// image-size: (radio)
    	$form_fields['image-size']['value'] = 'thumbnail';
    	$form_fields['image-size']['input'] = 'hidden';
    
    	// Caption: (radio)
    	$form_fields['image-caption']['value'] = 'caption';
    	$form_fields['image-caption']['input'] = 'hidden';
    
        }
        return $form_fields;
    }
    add_filter('attachment_fields_to_edit', 'ms_attachment_fields_to_edit', 11, 2);
    
    ?>

    :)

  21. idanska
    Member
    Posted 2 years ago #

    Hi rn2web and schoe, I found your correspondence very helpful since I faced a similar problem and the solution you came up with is almost perfect for me.
    The only thing is that for me the caption field won't disappear, I also need your help to adjust the code to hide the description field as well.
    Sorry if this is basic tweaks, but i'm a bit of a newbie and your help will... well, help.
    Thanks
    Idanska

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags