I am having the following issue with this version of Timthum: 2.8.10 (running on Wordpress installation - server Ubuntu):
- When i call images from the server hosting the website i got this error:
A TimThumb error has occured
The following error(s) occured:
Could not find the internal image you specified.
Query String : src=http://my-host.it/wp-content/files_mf/1346848579prog_no_pic.png
TimThumb version : 2.8.10
If i copy/paste http://my-host.it/wp-content/files_mf/1346848579prog_no_pic.png in the browser i can get the image...
- When i call image from external sites it works fine.
I have enabled:
define ('ALLOW_ALL_EXTERNAL_SITES', TRUE);
at line 33.
For me, the document root wasn't being set correctly, due to my virtual host setup.
I had to add the correct one in timthumb-config.php
define('LOCAL_FILE_BASE_DIRECTORY', "/home/www/mysite/");
This two steps worked for me:
Set to true ALLOW_ALL_EXTERNAL_SITES, in line ~33:
if(! defined('ALLOW_ALL_EXTERNAL_SITES') ) define ('ALLOW_ALL_EXTERNAL_SITES', TRUE);
comment line ~212
//$this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);
Source:
https://code.google.com/p/timthumb/issues/detail?id=363#c23
I just got over this problem which, in my case, had to do with the file path having a tilde in it.
Here's a link the solution I found:
http://elementdesignllc.com/2012/01/how-to-fix-timthumb-using-a-virtual-directory-url-contains-tildes/comment-page-1/#comment-7418
HTH!
I had the same problem on a Multisite installation of WordPress (3.5.1). The following fixed it:
In functions.php change
function get_image_url($img_src="") {
if($img_src!="") $theImageSrc = $img_src;
else $theImageSrc = wp_get_attachment_url(get_post_thumbnail_id($post_id));
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc);
if (isset($imageParts[1])) {
$theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
echo $theImageSrc;
}
to
function get_image_url($img_src="") {
if($img_src!="") $theImageSrc = $img_src;
else $theImageSrc = strstr(wp_get_attachment_url(get_post_thumbnail_id($post_id)), "/wp-content");
global $blog_id;
if (isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/', $theImageSrc);
if (isset($imageParts[1])) {
$theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
echo $theImageSrc;
}
Note: The only actual modification happens in the 3rd line (bold):
$theImageSrc = strstr( wp_get_attachment_url(get_post_thumbnail_id($post_id)) , "/wp-content");
First let me know are you using WordPress Multisite? If yes then you dont need edit anything in timthumb.php me do like it
This is what I have done to get timthumb to work with multisite. You need to add this code to your theme's functions.php file
<?php function get_image_path($src) {
global $blog_id;
if(isset($blog_id) && $blog_id > 0) {
$imageParts = explode('/files/' , $src);
if(isset($imageParts[1])) {
$src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
}
}
return $src;
}
?>
And then where the timthumb script is used in the theme, you need to modify to this:
<img src="<?php bloginfo('template_url'); ?>/includes/timthumb.php?q=100&w=180&h=200&zc=1&a=t&src=<?php echo get_image_path(get_post_meta($post->ID, 'postImage', true)); ?>" alt="" />
where postImage is the name of the meta field the holds the image URL.
have a nice.
Related
im trying to override the tpl of ps_categorytree module, but it didn't work
i tried to put the file under override like this:
override/themes/laber_ethan_home5/modules/ps_categorytree/views/templates/hook/ps_categorytree.tpl
-im using prestashop 1.7.1.1 and i bought a theme.
Help please!
you don't need to put this in override folder, simply use the modules folder that is in the active theme. The correct way to put your tpl file is:
/themes/laber_ethan_home5/modules/ps_categorytree/views/templates/hook/ps_categorytree.tpl
Hope it helps you, bye.
I wanted to add tpl from my module to theme so that my version of tpl will override the Prestashop but I found all stating that to create the same directory structure in the module that consists of theme name but theme name can change easily so did it in a different way
in my case, the file was included
form path
classes\pdf\HTMLTemplate.php
so I override it from my module
modules\module_name\override\classes\pdf\HTMLTemplate.php
and override method
protected function getTemplate($template_name) {
$template = false;
$default_template = rtrim(_PS_PDF_DIR_, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $template_name . '.tpl';
$overridden_template = _PS_ALL_THEMES_DIR_ . $this->shop->getTheme() . DIRECTORY_SEPARATOR . 'pdf' . DIRECTORY_SEPARATOR . $template_name . '.tpl';
$module_template = _PS_MODULE_DIR_ . $template_name;
if (file_exists($module_template)) {
$template = $module_template;
} else if (file_exists($overridden_template)) {
$template = $overridden_template;
} elseif (file_exists($default_template)) {
$template = $default_template;
}
return $template;
}
See
$module_template = _PS_MODULE_DIR_ . $template_name;
similarly, you can do it.
How to have access to wp-load.php ?
I can access it using the following
require_once("../../../../wp-load.php");
But I need to find it dynamically so I am using the following but none of them works.
require_once( dirname(__FILE__).'/../../../wp-load.php');
require_once( dirname(__FILE__)."/../../../wp-load.php");
require_once( ABSPATH.'wp-load.php');
require_once( ABSPATH."wp-load.php");
How to have access to localhost:8888/wordpress/wp-load.php?
Add below code snippets at beginning of file where you require to load wp-load.php
/* FindWPConfig - searching for a root of wp */
function FindWPConfig($dirrectory){
global $confroot;
foreach(glob($dirrectory."/*") as $f){
if (basename($f) == 'wp-config.php' ){
$confroot = str_replace("\\", "/", dirname($f));
return true;
}
if (is_dir($f)){
$newdir = dirname(dirname($f));
}
}
if (isset($newdir) && $newdir != $dirrectory){
if (FindWPConfig($newdir)){
return false;
}
}
return false;
}
if (!isset($table_prefix)){
global $confroot;
FindWPConfig(dirname(dirname(__FILE__)));
include_once $confroot."/wp-config.php";
include_once $confroot."/wp-load.php";
}
The same question is here.
Denzel Chia answer was :
Put the following in the beginning of your file that requires
wp-load.php
//include wp-config or wp-load.php
$root = dirname(dirname(dirname(dirname(__FILE__))));
if (file_exists($root.'/wp-load.php')) {
// WP 2.6
require_once($root.'/wp-load.php');
} else {
// Before 2.6
require_once($root.'/wp-config.php');
}
Hope it helps
What I am trying to do is to redirect 404 to the next possible page/category. The following is a detailed description of what I want:
If the user falls on the following:
www.domain.com/about/(any text that generates 404) it should automatically redirect to www.domain.com/about
www.domain.com/category/(any text that generates 404) it should automatically redirect to www.domain.com/category
www/domain.com/about/sub-about/(any text that generates 404) it should automatically redirect to www.domain.com/about/sub-about
I hope that describes what I am looking for. I would love if my fellows here post a solution to this. I have tried using the 404 redirected plugin but it is not auto redirecting. I am open to any solution as long as it works on wordpress.
Inserting a code like this one in the 404 script might work:
<?php
$Referrer = wp_get_referer( ) ;
if ( $Referrer = 'http://www.domain.com/' ) {
echo '<script type="text/javascript">window.location ="http://www.domain.com/about/";</script>' ;
}
elseif ( $Referrer = 'http://www.domain.com/about/' ) {
echo '<script type="text/javascript">window.location ="http://www.domain.com/about www.domain.com/category/";</script>' ;
}
elseif ( $Referrer = 'http://www.domain.com/about www.domain.com/category/' ) {
echo '<script type="text/javascript">window.location ="http://www.domain.com/category www/domain.com/about/sub-about/";</script>' ;
}
else {
echo "404 Message" ;
}
?>
I want to change my wordpress theme dynamically by user browser. So I found this code on the net and added it to my index.php file
add_filter('template', 'switch_theme_by_browser');
add_filter('stylesheet', 'switch_theme_by_browser');
function switch_theme_by_browser($theme) {
$browser = $_SERVER['HTTP_USER_AGENT'];
if(preg_match('/MSIE/i',$browser) && !preg_match('/Opera/i',$browser))
{
$theme = "twentyeleven";
}
elseif(preg_match('/Firefox/i',$browser))
{
$theme = "twentyten";
}
elseif(preg_match('/Chrome/i',$browser))
{
$theme = "Boxoffice";
}
return $theme;
}
After that it shows me "Fatal error: Call to undefined function add_filter() in /home/xxx/public_html/domain.com/index.php on line 17"
As I undertand the "add_filter()" should be a function that is built in wordpress.
As Dawson said, this needs to go in your /wp-content/themes/[theme]/functions.php file.
In wordpress root directory, put require( ABSPATH . WPINC . '/plugin.php' ); before require( ABSPATH . WPINC . '/functions.php' ); in file wp-settings.php.
I verified this solution at http://wordpress.org/support/topic/fatal-error-call-to-undefined-function-add_filter.
following the tutorial at http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/ i am trying to use wordpress' parse_request function to add some php-driven CSS... mostly style options set in my theme's options panel. i am aware that my code looks a little different from the author's, but i tried it his way already. i can add the
function kia_wp_head() {
wp_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css');
}
add_action('wp_print_styles', 'kia_wp_head');
//this shows up properly enqueued but when i click on it in source it just brings up a directory listing for the admin folder
function my_custom_wp_request( $wp ) {
if( isset($_GET['my-custom-content']) && $_GET['my-custom-content'] == 'css' ) {
# get theme options
header( 'Content-Type: text/css' ); ?>
body {
background-color: <?php echo 'red'; ?>
}
<?php
exit;
}
}
add_action( 'parse_request', 'my_custom_wp_request' );
but since the background never turns red, I am either not implementing this properly or the tutorial is missing a critical step. i've also tried the other method of putting the dynamic css in its own custom-css.php file, which is my ultimate goale, but i was just trying to see if i could interact with the parse request function properly:
function my_custom_wp_request( $wp ) {
if (
isset($_GET['my-custom-content'])
&& $_GET['my-custom-content'] == 'css'
) {
# get theme options
header( 'Content-Type: text/css' );
require dirname( __FILE__ ) . '/custom-css.php';
exit;
}
}
add_action( 'parse_request', 'my_custom_wp_request' );
here i'm not sure what dirname( FILE ) means exactly, but i have also tried using a hardcoded path and that didn't work either.
so how do i get parse_request to see my php-driven stylesheet?
/* EDIT FOR SOLUTION */
basically this doesn't work w/ wp_enqueue_style
wp_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css');
but DOES work as described at josephscott.org by inserting the style tag directly into the head
. '/admin?my-custom-content=css">
i found that it doesn’t work w/ wp_enqueue_script. it does work as written in the tutorial by manually adding the script tag to the header.