WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] image_default_link_type (29 posts)

  1. averyl
    Member
    Posted 1 year ago #

    I have image_default_link_type set to 'file', but images I upload are linked to the attachment page instead. Don't we get this option any more in 3.5?
    Thanks!

  2. When you upload the image, on the right side is an option to pick what you want the image to be linked to. Is that not working?

  3. averyl
    Member
    Posted 1 year ago #

    That's working. What's not working is the option to set it to the file by default, e.g. by using
    update_option('image_default_link_type','file');

  4. Checked in /wp-admin/options.php and it's getting set, but it looks like it's not getting read. Interesting. Works on 3.4.2.

  5. averyl
    Member
    Posted 1 year ago #

    Yeah it works in 3.4.2. Is there any way to disable attachment pages in 3.5 or in general and link straight to the file without a redirect?

  6. I'm not sure, so I'm gonna ask up the food chain. It works on the old media uploader, so I'm inclined to think it's in error.

  7. averyl
    Member
    Posted 1 year ago #

    Thanks!

  8. I went ahead and made http://core.trac.wordpress.org/ticket/22841 just to cover bases. I don't know enough about the new media code to be able to poke it myself :/ Just spent 40 minutes eyeing it. I'm going to keep kicking to see if it's obvious enough for me ;)

  9. averyl
    Member
    Posted 1 year ago #

    Thanks, I'm glad I've been of some help then.
    Kind of annoying though, I'll try to force it with js or I'll add a warning to our back end when we update to 3.5.
    If there's anyone who knows something that totally disables attachment pages (also the drop down?), please let me know :)

  10. Andrew Nacin
    Lead Developer
    Posted 1 year ago #

    As explained on the ticket, this option never forced anything. It only set a default, and it's a default that we change per-user.

    You can use set_user_setting( 'urlbutton', 'file' ) to set a user default.

  11. averyl
    Member
    Posted 1 year ago #

    That works great, thanks!
    I know it just sets a default, but it would be even more interesting if there was an option to totally disable attachment pages. Now I'm redirecting them all to the files.
    But thanks, this is what I was looking for!

  12. piichi
    Member
    Posted 1 year ago #

    it seems that in wp-3.5.0 all of this 3 options are not settable anymore:

    update_option('image_default_align', 'none' );
    update_option('image_default_link_type', 'none' );
    update_option('image_default_size', 'large' );

    it is always very useful, to set those 3 options inside the theme functions.php itself, specially for some authors, that do not understand so much about what is a attachment-page or file link and such. those users only click on the default “OK” Buttons :-(

    same as “averyl” me too, i’d like to know, if there's anyone who knows something that totally disables attachment pages (also the drop down?), please let me/us know :)

  13. averyl
    Member
    Posted 1 year ago #

    For me the solution Andrew gave works. It sets the option to the media file as default, but it doesn't remove any attachment pages from older post. I don't think totally disabling them is possible, but you might want to redirect them all. I use this:

    set_user_setting('urlbutton', 'file' );
    function gg_attachment_redirect() {
    	global $post;
    	if (is_attachment()) {
    		wp_redirect(wp_get_attachment_url( $post->ID ), 301);
    	exit;
    	}
    }
    add_action('template_redirect', 'gg_attachment_redirect', 1);

    However, this won't be a good solution if you need a direct link to the file, like for Fancybox for example.

  14. averyl
    Member
    Posted 1 year ago #

    Oh and if you need all the images to be aligned the same, just don't add any css. People will still be able to set the alignment, but it won't do anything. Maybe override the editor-style css.css as well so people see that it doesn't work before they post.
    Image default size should also be doable with css, though you keep the original size then. That's a problem for for really big images... There are a lot of plugins to resize the image before upload.

    Of course, these options were really useful, so I hope we see them again in the next version. I also hope there will be an option to totally disable the attachment pages, because quite al lot of people don't seem to use them.

  15. piichi
    Member
    Posted 1 year ago #

    Thanx. Until 3.4.2 i could easily also set the align pull-down to tr.align {display:none !important;}... But this too doesn’t work anymore ...

    Basically my idea of a better usability is always NOT to show un-useful or confusing options to the “non-professional” authors.

    So rather then controlling this with CSS (what I also do of course) - i try them not to “let them see” these options or if they already incedently used them, and therefore they are saved - to override them again by update_option (...)

  16. averyl
    Member
    Posted 1 year ago #

    You can remove these buttons if you create a custom admin.css and add the following:

    #content_justifyleft,
    #content_justifyright,
    #content_justifycenter,
    #content_justifyfull {
    	display: none;
    }

    To have even more control, add this to function.php:

    function custom_tinymce_options($initArray){
     	$initArray['theme_advanced_buttons1'] = 'styleselect,bold,italic,strikethrough,underline,|,bullist,numlist,blockquote,hr,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,|,spellchecker';
     	$initArray['theme_advanced_buttons2'] = 'formatselect,forecolor,|,pastetext,pasteword,removeformat,|,charmap,sub,sup,|,outdent,indent,|,undo,redo';
     	return $initArray;
    }
    add_filter('tiny_mce_before_init', 'custom_tinymce_options');

    Then remove the buttons you don't want! :)

  17. piichi
    Member
    Posted 1 year ago #

    thanx again, but i try to get rid of them in the new media center... - the so called Attachment Display Settings - they have no special css-class or id’s anymore

  18. averyl
    Member
    Posted 1 year ago #

    It does? Just add

    .attachment-display-settings {
    	display: none;
    }

    to your admin.css or whatever you called it.

  19. piichi
    Member
    Posted 1 year ago #

    but then ALL options are gone,
    what if you just want get rid of align for ex.?

  20. averyl
    Member
    Posted 1 year ago #

    Hmm, the only way to do it is

    .attachment-display-settings .alignment {
    	display: none;
    }

    but then the label's still there. Of course it prevents people from setting it differently, but it's not the cleanest solution.

  21. piichi
    Member
    Posted 1 year ago #

    best would be, to get these 3 options back again:

    update_option('image_default_align', 'none' );
    update_option('image_default_link_type', 'none' );
    update_option('image_default_size', 'large' );

    hope this will be done in wp-3.5.1
    thanx anyway

  22. averyl
    Member
    Posted 1 year ago #

    set_user_setting('urlbutton', 'file' );

    sets links the attachment to the file by default. But the author can still change it to the attachment page.

    function gg_attachment_redirect() {
    	global $post;
    	if (is_attachment()) {
    		wp_redirect(wp_get_attachment_url( $post->ID ), 301);
    	exit;
    	}
    }
    add_action('template_redirect', 'gg_attachment_redirect', 1);

    only redirects all the attachment pages to the file, even if it was set to attachment page.

    You just add this code to your functions.php. I'm not sure if it would be useful to do his only for a specific group since you can change the default setting anyway and if you redirect, your setting won't make any difference.

  23. drsprite
    Member
    Posted 1 year ago #

    piichi,

    I was able to get those 3 update_option to work. It works great in WP 3.5.1. Thanks!

    I did it like this

    function mytheme_setup() {
    	// Set default values for the upload media box
    	update_option('image_default_align', 'center' );
    	update_option('image_default_link_type', 'none' );
    	update_option('image_default_size', 'large' );
    }
    add_action('after_setup_theme', 'mytheme_setup');
  24. piichi
    Member
    Posted 1 year ago #

    drsprite,

    yes! here too!
    thanks to 3.5.1 everything works well.

    code is poetry ☆彡

  25. averyl
    Member
    Posted 1 year ago #

    That's still not working for me... So I use this instead:

    set_user_setting('urlbutton', 'file' );
    set_user_setting('imgsize', 'large' );
    set_user_setting('image_default_link_type', 'file' );
    set_user_setting('align', 'none' );
  26. aoidja
    Member
    Posted 1 year ago #

    Is there a way to manually change the image_default_size?

    And for

    function mytheme_setup() {<br />
    	// Set default values for the upload media box<br />
    	update_option('image_default_align', 'center' );<br />
    	update_option('image_default_link_type', 'none' );<br />
    	update_option('image_default_size', 'large' );<br />
    }<br />
    add_action('after_setup_theme', 'mytheme_setup');

    Which are placeholder names that you are using in there?

    *backticks not working for me?

  27. Hemant Aggarwal
    Member
    Posted 1 year ago #

    Go to http://www.example.com/wp-admin/options.php

    where example.com needs to be replaced by your site name. Here you will find all the settings and also the "image_default_size".

    NOTE : Whenever you update or reinstall WordPress your settings will be removed and you will have to redo them.

  28. nookaimrs
    Member
    Posted 1 year ago #

    thank

  29. nookaimrs
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags