From e621a3239a4868ed115d8d0152f8a2e9b0c8360f Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 15 Aug 2008 15:40:35 +0000 Subject: [PATCH] Image default options for size, alignment and link type. Props tellyworth. fixes #7520 git-svn-id: https://develop.svn.wordpress.org/trunk@8653 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 74 +++++++++++++++++++++++++----------- wp-admin/includes/schema.php | 7 ++++ wp-admin/options-misc.php | 48 ++++++++++++++++++++++- wp-includes/version.php | 2 +- 4 files changed, 106 insertions(+), 25 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index db0f5e0c4a..6481ee4ee2 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -520,10 +520,27 @@ function media_upload_library() { return wp_iframe( 'media_upload_library_form', $errors ); } +// produce HTML for the image alignment radio buttons with the specified one checked +function image_align_input_fields($post, $checked='') { + + $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'); + if ( !array_key_exists($checked, $alignments) ) + $checked = 'none'; + + $out = array(); + foreach ($alignments as $name => $label) { + + $out[] = ""; + } + return join("\n", $out); +} + +// produce HTML for the size radio buttons with the specified one checked function image_size_input_fields($post, $checked='') { // get a list of the actual pixel dimensions of each possible intermediate version of this image - $sizes = array(); $size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size'); foreach ( $size_names as $size => $name) { @@ -555,6 +572,27 @@ function image_size_input_fields($post, $checked='') { ); } +// produce HTML for the Link URL buttons with the default link type as specified +function image_link_input_fields($post, $url_type='') { + + $file = wp_get_attachment_url($post->ID); + $link = get_attachment_link($post->ID); + + $url = ''; + if ( $url_type == 'file' ) + $url = $file; + elseif ( $url_type == 'post' ) + $url = $link; + + return "
+ + + + \n"; +} + function image_attachment_fields_to_edit($form_fields, $post) { if ( substr($post->post_mime_type, 0, 5) == 'image' ) { $form_fields['post_title']['required'] = true; @@ -567,17 +605,10 @@ function image_attachment_fields_to_edit($form_fields, $post) { $form_fields['align'] = array( 'label' => __('Alignment'), 'input' => 'html', - 'html' => " - - - - - - - - \n", + 'html' => image_align_input_fields($post, get_option('image_default_align')), ); - $form_fields['image-size'] = image_size_input_fields($post); + + $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size')); } return $form_fields; } @@ -654,14 +685,7 @@ function get_attachment_fields_to_edit($post, $errors = null) { 'url' => array( 'label' => __('Link URL'), 'input' => 'html', - 'html' => " -
- - - - \n", + 'html' => image_link_input_fields($post, get_option('image_default_link_type')), 'helps' => __('Enter a link URL or click above for presets.'), ), 'menu_order' => array( @@ -1312,6 +1336,10 @@ function type_form_image() { $alt_help = __('Also used as alternate text for the image'); } + $default_align = get_option('image_default_align'); + if ( empty($default_align) ) + $default_align = 'none'; + return ' @@ -1341,13 +1369,13 @@ function type_form_image() { diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 4e75d56786..3e7ca95dc0 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -262,6 +262,13 @@ function populate_options() { add_option('large_size_w', 1024); add_option('large_size_h', 1024); + // 2.7 + add_option('large_size_w', 1024); + add_option('large_size_h', 1024); + add_option('image_default_link_type', 'file'); + add_option('image_default_size', ''); + add_option('image_default_align', ''); + // Delete unused options $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins'); foreach ($unusedoptions as $option) : diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index 42c04a713f..233c00d93c 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -71,6 +71,52 @@ include('admin-header.php'); + + + + + + + + + + + + + + + +

- + - + - + - +
+ 'Auto', 'thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size'); + foreach ($size_names as $size => $name) { ?> + /> + + +
+ 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'); + foreach ($alignments as $align => $name) { ?> + /> + + +
+ 'None', 'post' => 'Post URL', 'file' => 'File'); + foreach ($link_types as $type => $name) { ?> + /> + + +
@@ -99,7 +145,7 @@ include('admin-header.php');

- +

diff --git a/wp-includes/version.php b/wp-includes/version.php index 71d3f62791..c95fa9f889 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -15,6 +15,6 @@ $wp_version = '2.7-bleeding'; * * @global int $wp_db_version */ -$wp_db_version = 8586; +$wp_db_version = 8645; ?>