Changeset 928294
- Timestamp:
- 06/07/2014 09:45:06 PM (12 years ago)
- Location:
- picturefillwp/trunk
- Files:
-
- 4 edited
-
inc/class-model-picturefill-wp.php (modified) (2 diffs)
-
inc/class-picturefill-wp.php (modified) (1 diff)
-
picturefill-wp.php (modified) (2 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
picturefillwp/trunk/inc/class-model-picturefill-wp.php
r888529 r928294 19 19 20 20 static function syntax_present($DOMDocument, $html){ 21 $libxml_previous_error_state = libxml_use_internal_errors(true); 21 22 $DOMDocument->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . $html); 23 apply_filters('picturefill_wp_syntax_present_libxml_errors', libxml_get_errors(), $html, $DOMDocument); 24 libxml_clear_errors(); 25 libxml_use_internal_errors($libxml_previous_error_state); 22 26 $spans = $DOMDocument->getElementsByTagName('span'); 23 27 if(0 === $spans->length){ … … 33 37 34 38 static function get_images($DOMDocument, $html){ 39 $libxml_previous_error_state = libxml_use_internal_errors(true); 35 40 $DOMDocument->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' . $html); 41 apply_filters('picturefill_wp_get_images_libxml_errors', libxml_get_errors(), $html, $DOMDocument); 42 libxml_clear_errors(); 43 libxml_use_internal_errors($libxml_previous_error_state); 36 44 return $DOMDocument->getElementsByTagName('img'); 37 45 } -
picturefillwp/trunk/inc/class-picturefill-wp.php
r888529 r928294 61 61 } 62 62 63 public function cache_picturefill_output($html, $content_type){ 64 global $wp_scripts, $page; 65 if(!isset($content_type)){ 66 return $html; 67 } 68 $post_id = get_the_ID(); 63 public function cache_picturefill_output($html, $content_type = 'depreciated'){ 64 global $wp_scripts; 65 $html_hash = md5($html); 69 66 $cache_duration = apply_filters('picturefill_wp_cache_duration', 86400); 70 $cached_output = get_transient('picturefill_wp_ ' . $content_type . '_output_' . $post_id . '_p' . $page);71 if( is_singular() && is_main_query() && !empty($cached_output) && (get_option('_transient_timeout_picturefill_wp_' . $content_type . '_output_' . $post_id . '_p' . $page) - $cache_duration) > get_the_modified_time('U') && (get_option('picturefill_wp_update_timestamp') - $cache_duration) > get_the_modified_time('U')){67 $cached_output = get_transient('picturefill_wp_output_' . $html_hash); 68 if(!empty($cached_output)){ 72 69 wp_enqueue_script('picturefill'); 73 70 return $cached_output; 74 71 }else{ 75 72 $output = $this->replace_images($html); 76 if( is_singular() && is_main_query() && in_array('picturefill', $wp_scripts->queue)){77 set_transient('picturefill_wp _' . $content_type . '_output_' . $post_id . '_p' . $page, $output, $cache_duration);73 if($output !== $html){ 74 set_transient('picturefill_wp _output_' . $html_hash, $output, $cache_duration); 78 75 } 79 76 return $output; -
picturefillwp/trunk/picturefill-wp.php
r888529 r928294 6 6 Description: A wordpress plugin to load responsive/retina images via picturefill.js. 7 7 Author: Kyle Reicks 8 Version: 1.3. 28 Version: 1.3.3 9 9 Author URI: http://github.com/kylereicks/ 10 10 */ … … 12 12 define('PICTUREFILL_WP_PATH', plugin_dir_path(__FILE__)); 13 13 define('PICTUREFILL_WP_URL', plugins_url('/', __FILE__)); 14 define('PICTUREFILL_WP_VERSION', '1.3. 2');14 define('PICTUREFILL_WP_VERSION', '1.3.3'); 15 15 16 16 require_once(PICTUREFILL_WP_PATH . 'inc/class-picturefill-wp.php'); -
picturefillwp/trunk/readme.txt
r888529 r928294 4 4 Tags: images, retina, retina images, responsive images, picturefill, picturefillJS, picturefill.js, HDPI, High DPI 5 5 Requires at least: 3.2 6 Tested up to: 3.9 7 Stable tag: 1.3. 26 Tested up to: 3.9.1 7 Stable tag: 1.3.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 25 25 If you are installing Picturefill.WP on a large and image heavy site, you may want to consider using another plugin like [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) to create the new image sizes for existing posts and pages. 26 26 27 ####500 or 504 server errors 28 29 These errors are related to the slow loading listed above. If the server reaches its timeout limit before it is finished processing new images, it will return a 500 or 504 error. Refreshing the page usually gives the server the time it needs to finish processing the images. On some image-heavy posts, it may take more than one refresh. 30 27 31 ####Image Sizes 28 32 … … 35 39 ####Errors and Warnings 36 40 37 When using Picturefill.WP with your website, you may occasionally notice a warning very much like the following: 38 39 [Mon Jan 01 12:00:00 2000] [error] [client 999.999.99.99] PHP Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : a in Entity, line: 17 in /server/www/wp-content/plugins/picturefill/inc/class-model-picturefill-wp.php on line 20 40 41 This error indicates improperly formed HTML. In this case, the `Unexpected end tag : a` comes from nested links. If you are seeing errors like this on your WordPress site, you may want to consider implementing an [error logging](http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Logging) system, or alternatively suppressing errors by adding `error_reporting(0);` and `@ini_set('display_errors', 0);` to `wp-config.php`. 42 43 Additionally, the PHP DOM parser `DOMDocument` often has trouble with HTML5 elements and may throw an error if your post includes a `<canvas>` element, or a `<section>` element, for example. All the more reason to implement an error handling system on production sites. 41 As of version 1.3.3 Picturefill.WP suppresses errors and warnings in parsing the DOM. Errors and warnings can now be collected via the `picturefill_wp_syntax_present_libxml_errors` and `picturefill_wp_get_images_libxml_errors` filters. 42 43 add_filter('picturefill_wp_get_images_libxml_errors', 'handle_errors'); 44 45 function handle_errors($errors){ 46 foreach($errors as $error){ 47 // Handle errors here. 48 } 49 } 44 50 45 51 ####Theme CSS … … 116 122 The standard version of [picturefill.js](https://github.com/scottjehl/picturefill) will work well enough with Picturefill.WP; however, Picturefill.WP has a slightly diferent goal than picturefill.js. Picturefill.js aims to pollyfill the proposed `<picture>` element. It expects a special `<picture>` like markup, and outputs the appropriate `<img>`, but the resulting `<img>` does not include a class, id or other attribute. The generated `<img>` tags can only be targeted by the attributes of its parent elements. Picturefill.WP aims to take an `<img>` and then output an `<img>` exactly like it, apart form the width or pixel density. This way, `<img>` tags can be targeted without regard to the `<picture>` syntax. 117 123 118 = Is the picture element really the direction responsive images are heading? = 119 120 The debate over what to do about responsive images has been long and vigorous, but the `picture` element is happening. The major browsers have anounced that they will be adding support in the very near future. The future of this plugin will depend on what that support looks like, both in the browser and in the WordPress core. Picturefill.WP was never intended to be a permanent solution for responsive images. One day soon, it may be completely unnecessary. In the mean time, Picturefill.WP provides a serviceable solution that can be turned off at any time. Once deactivated, all images return to normal, as though the plugin had never been used. 124 = Are there any plans to update this plugin to Picturefill 2.0 = 125 126 A new version of Picturefill.WP using Picturefill 2.x is in the works. Because of significant diferences between Picturefill 1.x and Picturefill 2.x, the new Picturefill.WP 2 will be maintained alongside the original Picteufill.WP 1.3.x. I will update this plugin with more details as they become available. 127 121 128 122 129 == Advanced Use == … … 137 144 138 145 == Changelog == 146 147 = 1.3.3 = 148 * [Suppress warnings](https://github.com/kylereicks/picturefill.js.wp/issues/29) from DOM parsing 149 * [Update transient caching](https://github.com/kylereicks/picturefill.js.wp/issues/31) to use a hash as an identifier. 139 150 140 151 = 1.3.1 = … … 196 207 == Upgrade Notice == 197 208 198 = 1.3. 2=199 Corrects an issue with IE7 and below, and enqueues picturefill.js when manual picturefill syntax is present. 209 = 1.3.3 = 210 [Suppress warnings](https://github.com/kylereicks/picturefill.js.wp/issues/29) from DOM parsing and [update transient caching](https://github.com/kylereicks/picturefill.js.wp/issues/31) to use a hash as an identifier.
Note: See TracChangeset
for help on using the changeset viewer.