alex20hz
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Add new data attribute into get_image_tag functionThe solution:
//Fancybox and Lazy load support
function add_fancybox_lazyload($content) {
global $post;
$pattern =”/<a(.*?)href=(‘|\”)(.*?).(bmp|gif|jpeg|jpg|png)(‘|\”)(.*?)>/i”;
$replacement = ‘<a$1href=$2$3.$4$5 class=”fancybox”>’;
$content = preg_replace($pattern, $replacement, $content);$search = ‘/src\=\”([^\s]+(?=\.(jpg))\.\2)\”/’;
$content = replacer($content, $search, ‘/src/’, ‘data-original’);
$search = ‘/img\ class\=\”/’;
$content = replacer($content, $search, ‘/class\=\”/’, ‘class=”lazy ‘);
$search = ‘/alt/’;
$content = replacer($content, $search, ‘/alt/’, ‘src=”grey.gif”‘);return $content;
}function replacer($src, $search, $find, $replace){
preg_match_all($search, $src, $result, PREG_OFFSET_CAPTURE);
foreach($result[0] as $entry){
$org = $entry[0];
$rep = preg_replace($find, $replace, $entry[0]);
$org = “/” .str_replace(array(“=”,”:”,”/”,”.”,”-“,”_”,'”‘,”‘”,” “), array(“\=”,”\:”,”\/”,”\.”,”\-“,”\_”,’\”‘,”\'”,”\ “), $org). “/”;
$src = preg_replace($org, $rep, $src);
}
return $src;
}add_filter(‘the_content’, ‘add_fancybox_lazyload’);
Forum: Fixing WordPress
In reply to: Add new data attribute into get_image_tag functionMy code:
//Add fancybox class
define(“IMAGE_FILETYPE”, “(bmp|gif|jpeg|jpg|png)”, true);function add_fancyboxlazyloading($string) {
$pattern = ‘/<a(.*?)href=”(.*?).(bmp|gif|jpeg|jpg|png)”(.*?)><img (.*?) /’;
$replacement = ‘<a$1href=”$2.$3″ class=\’fancybox\’><img src=”#” data-orignal=”$2″ class=”lazy” ‘;
return preg_replace($pattern, $replacement, $string);
}add_filter(‘the_content’, ‘add_fancyboxlazyloading’);
Trying to get this string:
<img src=”loading.gif” data-orignal=”https://localhost/wp-content/uploads/2011/10/aw2011″ class=”lazy” alt=”” title=”021700_Summer_Desserts_2011_Sleekster_lid” width=”560″ height=”595″ class=”alignnone size-medium wp-image-1208″ />Forum: Fixing WordPress
In reply to: Add new data attribute into get_image_tag functionMate, did you solve this? I have the same problem and trying to solve it.
Forum: Plugins
In reply to: All-In-One-SEO plugin not working on version 2.7rychag: chmod -R 777 your wp-content.
Forum: Plugins
In reply to: All-In-One-SEO plugin not working on version 2.7Any progress?
Forum: Plugins
In reply to: Template pages issueTested this code:
<?php
// let’s generate info appropriate to the page being displayed
if (is_home()) {
// we’re on the home page, so let’s show a list of all top-level categories
echo “home”;
} elseif (is_category(‘Beauty & Health’)) {
// we’re looking at a single category view, so let’s show _all_ the categories
echo “beauty-health”;
} elseif (is_single()) {
echo “single”;
} elseif (is_page()) {
// we’re looking at a static page. Which one?
if (is_page(‘Archives’)) {
// our about page.
echo “<p>This is my about page!</p>”;
} elseif (is_page(‘Colophon’)) {
echo “<p>This is my colophon page, running on WordPress ” . bloginfo(‘version’) . “</p>”;
} else {
// catch-all for other pages
echo “check”;
}
} else {
// catch-all for everything else (archives, searches, 404s, etc)
echo “Error”;
} // That’s all, folks!
?>AND when i try is_category(‘Beauty & Health’) it doesn’t work but with in_category(‘4’) it works fab. Why?
Forum: Fixing WordPress
In reply to: query_posts (category_name)Ok I’ve no idea why this one doesnt work on the site. I checked with one other and test on a default theme and it worked!
Forum: Fixing WordPress
In reply to: query_posts (category_name)Must test on a diffrent site…. strange!
Forum: Fixing WordPress
In reply to: query_posts (category_name)there must be more users than me that uses this code on their pages? :S
Forum: Fixing WordPress
In reply to: query_posts (category_name)It’s works with query_posts(‘page_id=7’); and query_posts(‘pagename=about’); but not the cat or category_name. Strange! This worked in the 2.6 version. Should i downgrade the site to 2.6 again?
Forum: Fixing WordPress
In reply to: query_posts (category_name)filosofo:
but i use query_posts(‘category_name=fashion&showposts=7’); now and it’s it doesn’t work.