Fritser
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Static homepage the_content not working as expectedNever mind… forgot to add wp_reset_query() to my sidebar widget that gets the news…
Forum: Fixing WordPress
In reply to: Static homepage the_content not working as expectedOk, I have removed front-page.php and renamed it to page-home.php. Home still set as the static page but still the home page gets the_content() from the last news item.
I really don’t understand what’s wrong here.Forum: Fixing WordPress
In reply to: All image sizes being generated, only need one.Found a function that does what I need here.
See code below:
add_filter('wp_generate_attachment_metadata','replace_uploaded_image'); /* limits image size to large setting */ function replace_uploaded_image($image_data) { if (!isset($image_data['sizes']['large'])) return $image_data; // paths to the uploaded image and the large image $upload_dir = wp_upload_dir(); $uploaded_image_location = $upload_dir['basedir'] . '/' .$image_data['file']; $large_image_location = $upload_dir['path'] . '/'.$image_data['sizes']['large']['file']; // delete the uploaded image unlink($uploaded_image_location); // rename the large image rename($large_image_location,$uploaded_image_location); // update image metadata and return them $image_data['width'] = $image_data['sizes']['large']['width']; $image_data['height'] = $image_data['sizes']['large']['height']; unset($image_data['sizes']['large']); return $image_data; }Forum: Fixing WordPress
In reply to: All image sizes being generated, only need one.I changed both large large and medium sizes to 0, now 2 less images are being generated.
What I realize now however is that WordPress saves a backup of the image. Which is definitely not necessary and the biggest problem because the site has used a lot of high quality pictures only as thumbnails.
Forum: Plugins
In reply to: get_image_tag & apply_filter not working to add span tagI solved it, kind of.
<?php $string1 = "alignleft"; $string2 = "alignright"; $content = get_the_content(); if(strstr($content,$string1) || strstr($content,$string2) ) { $content = str_replace('<p><img class="alignleft ', '<div class="photoleft"><span></span><img class="', $content); $content = str_replace('<p><img class="alignright ', '<div class="photoright"><span></span><img class="', $content); $content = str_replace('height="95" />', 'height="95" /></div><p>', $content); echo $content; } else { the_content('Read complete article'); } ?>Also I was working on the code below, which doesn’t work because WordPress removes the empty span tags. Other than that it functions fine. The problem I had was that te size attribute defaults to medium.
<?php function span_my_image_tag($html, $id , $class, $title, $size='thumbnail'){ global $class; $class = $fubar; $html = str_replace('<img', '<div class="rounder"><span></span><img', $html); $html = str_replace('alt=""', 'alt="'.$title.'"', $html); $html = str_replace('height="95" />', 'height="95" /></div>', $html); return $html; } add_filter('get_image_tag','span_my_image_tag',10,5); ?>Forum: Plugins
In reply to: get_image_tag & apply_filter not working to add span tagDoes anyone know how to fix this? Or just a hint 🙂