Changeset 391641
- Timestamp:
- 06/01/2011 10:19:33 AM (15 years ago)
- Location:
- related-images
- Files:
-
- 7 added
- 4 edited
-
tags/1.2.3 (added)
-
tags/1.2.3/readme.txt (added)
-
tags/1.2.3/related-images.class.php (added)
-
tags/1.2.3/related-images.js (added)
-
tags/1.2.3/related-images.php (added)
-
tags/1.2.3/screenshot-1.png (added)
-
tags/1.2.3/style.css (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/related-images.class.php (modified) (3 diffs)
-
trunk/related-images.js (modified) (1 diff)
-
trunk/related-images.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
related-images/trunk/readme.txt
r391166 r391641 5 5 Tested up to: 3.2 beta2 6 6 7 The plugin creates a backend box where you can search your media archive and relate images to the current post .7 The plugin creates a backend box where you can search your media archive and relate images to the current post to a given position. 8 8 9 9 == Description == 10 10 11 Sometimes you dont want all images inside the post. Related images fix this and the current version let you add positions to the images, for example "Firstpage Top" or "Article Top". Then you use a template tag to display the pictures on yor site. 11 Sometimes you dont want all images inside the post. Related images fix this and the current version let you add positions to the images, for example "Firstpage Top" or "Article Top". 12 13 Then you use a template tag to display the pictures on yor site. 14 12 15 The template tag looks like this: related_image('left_firstpage', '200', '200', 'image class'); You add the position, width, height and optional class to the image. 16 13 17 This can be usefull when you use WordPress as a cms and want to position images better then inside the posts 14 15 Version 1.0 only have 4 positions (top_firstpage,right_firstpage,left_firstpage,top_article), this will be moved to a config in the future for better use.16 17 Update: fron version 1.2 you can create your positions yourself18 18 19 19 == Installation == 20 20 21 21 1. Drop plugin in the plugin folder and activate 22 2. Add positions under settings -> Related Images 22 23 3. Done 23 24 … … 26 27 27 28 == Changelog == 29 30 = 1.2.3 = 31 * Added a remove method, so the "Quick Edit" will not remove related images 32 * Added better cheack for revisions and post_id:s 28 33 29 34 = 1.2.2 = -
related-images/trunk/related-images.class.php
r391166 r391641 82 82 83 83 } 84 85 // returne the "default" post_id, not the revision 86 function get_correct_post_id($post_id){ 87 88 //$revision = wp_is_post_revision ($post_id); 89 //if($revision){ 90 //$post_id = $revision; 91 //} 92 //$post = get_post ($post_id); 93 94 95 96 $post_id_parent = get_post($post_id)->post_parent; 97 98 // det finns inga revisions 99 if($post_id_parent != 0){ 100 $post_id = $post_id_parent; 101 } 102 103 return $post_id; 104 } 84 105 85 106 // save on 'save_post' 86 107 function save_related_images($post_id){ 87 108 global $wpdb; 88 89 // save to the correct post_id90 $post_id = get_post($post_id)->post_parent;91 109 110 // allways use the "default" post_id, not the revision one 111 $post_id = $this->get_correct_post_id($post_id); 112 92 113 // get saved positions 93 114 if($_POST['saved_img_position']){ … … 271 292 } 272 293 294 // remova image 295 function remove_image(){ 296 global $wpdb, $post; 297 298 if (!wp_verify_nonce($_POST['image_search_nonce'],__FILE__)){ 299 die(); 300 } 301 302 // get the search string 303 $img_id = $_POST['img_id']; 304 $post_ID = $_POST['post_ID']; 305 306 // get saved options 307 $related_images = get_option($post_ID."_related_images"); 308 309 // if there is only one saved, remove it all, or unset a specific image and then update the options 310 $len = sizeof($related_images); 311 312 if($related_images == 1){ 313 delete_option($post_ID."_related_images"); 314 } else { 315 unset($related_images[$img_id]); 316 update_option($post_ID."_related_images", $related_images); 317 } 318 319 die(); 320 321 } 322 323 273 324 // run the search 274 325 function do_image_search(){ … … 282 333 283 334 // get the search string 284 $image_search_string = "%". esc_attr($_POST['image_search_string'])."%";335 $image_search_string = "%".$_POST['image_search_string']."%"; 285 336 286 337 // had to create the search by myself, did not find any native?? -
related-images/trunk/related-images.js
r389263 r391641 25 25 var value = jQuery(this).val(); 26 26 var img_id = jQuery(this).attr('data-img-id'); 27 var image_search_nonce = jQuery("#image_search_nonce").val(); 28 var post_ID = jQuery("#post_ID").attr('value'); 29 27 30 if(value === 'Remove'){ 28 31 jQuery('#img_' + img_id).css({ 'backgroundColor':'#fbe986' }).fadeOut(300, function() { jQuery(this).remove(); }); 32 33 // run the image remove 34 jQuery.post(ajaxurl, { action : 'remove_related_images', img_id : img_id, post_ID : post_ID, image_search_nonce : image_search_nonce } ); 35 36 29 37 } 30 38 return false; -
related-images/trunk/related-images.php
r391167 r391641 5 5 Description: Relate one or more images to a post 6 6 Author: johannesfosseus 7 Version: 1.2. 27 Version: 1.2.3 8 8 */ 9 9 … … 18 18 wp_enqueue_script('related_images_js', WP_PLUGIN_URL.'/related-images/related-images.js', array('jquery')); 19 19 wp_enqueue_style('related_images_css', WP_PLUGIN_URL.'/related-images/style.css'); 20 add_action('wp_ajax_search_related_images', array($related_images, 'do_image_search')); // k�r s�ket 20 add_action('wp_ajax_search_related_images', array($related_images, 'do_image_search')); // do the search 21 add_action('wp_ajax_remove_related_images', array($related_images, 'remove_image')); // remove a image 21 22 } 22 23
Note: See TracChangeset
for help on using the changeset viewer.