The timthumb function is not working after the security setting of web server is raised.
Images with "http://...." in URL are blocked.
I have found that <?php echo $img ?> was used to load the image.
Original code:
<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?h=100&w=100&zc=1&src=<?php echo $img ?>" alt="<?php the_title_attribute(); ?>" width="100" height="100" />
Would someone please tell me how can I modify the code so that instead of
http://domain.com/wp-content/themes/a/scripts/timthumb.php?h=100&w=100&zc=1&src=http://domain.com/wp-content/uploads/thumbnail.jpg
the image URL will be
http://domain.com/wp-content/themes/a/scripts/timthumb.php?h=100&w=100&zc=1&src=../wp-content/uploads/2013/10/thumbnail.jpg
?
The code inside timthumb.php is super long. I will post the code if it's needed.
I know almost nothing about php code and only use plugins to build Wordpress websites.
You would have save my life. Thank you very very much!
It depends on where it is getting $img value from. If this is just a field on your article (through the extra parameters on the bottom), you could simply alter the url in your post. Alternatively, you could process the path, stripping out the http://domain.com/ and replace it with ../,
a la:
$img = str_replace("http://domain.com/", "../", $img);
just before echoing it out on to the page.
Related
Hi i want to show images from different disk.
Here is my code.
is it possible to do that ?
$a = "D:/img/1.jpg";
<img src="<?php echo $a; ?>" alt="...">
Im using this on my localhost.This is not for the web.
i add screenshot here.
when i come above the img it shows the link. but not show img. and i use lightbox.
but without lightbox its not show again.
example
The sample you provided/attached is only doable if you load the html file directly to your browser. It is not possible if you load it via localhost. In your case, you will have to do something like this:
<?php
$image = file_get_contents('D:/img/1.jpg');
$image_codes = base64_encode($image);
?>
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />
Reference: How to retrieve and show images from another drive using src attribute in <img> tag?
I'd suppose to use such URLs with protocol: $a = 'file:///D:/img/1.jpg';
my image is saved in a file ....and i have saved its path in the database....when i am fetching the image path from the database and trying to display it on a given position on the web page it is simply not getting displayed instead a text "loading..." is appearing there
furthermore the inspect element is displaying the image path clearly, here it is
'<img id="image" alt="mgm axis" title="mgm axis" src="polybazaar_files/images/1.jpg" style="display: block;"></img>'
now part of my code is here
while( $result=mysqli_fetch_array($runquery))
{$GLOBALS['image']=$result['image'];}
<img src="<?php echo $image; ?>" title="<?php echo $prodname; ?>" alt="<?php echo $prodname; ?>" id="image" />
where on a different page echo'<img src="'.($result['image']).'" />'; worked for the same image on the database....
i tried the suggestion mentioned here Displaying an image using a php variable and also tried suggestion mentioned at other places but none of them work
also my page has lot of java script in between ......are they creating problem?
any valuable and informative reasons or solutions will be appreciated ....thanks
got it fixed .....
actually the address at the top of my script
<base href="http://polybazaar.in/shop/" />
needed to be put inside the comment, since i am working on a local server....or the address of a DEFAULT TARGET should be given if one wants its server request to be accessed from that URL.....
thanks all for their valuable comments
I want to ask about calling the images in a folder with php
The first I've made a file to declare the image url
$url_folder_gambar = 'http://localhost/mysite/assets/img/';
I then call the php but the picture did not come out. what's wrong?
<img src="<?php echo $url_folder_gambar . people.png?>"
please help me
It looks like a syntax error. Try this:
<img src="<?php echo $url_folder_gambar;?>people.png" />
$url_folder_gambar path of the image file, some thing like http://domain/path/imagefolder/
<img src="<?php echo $url_folder_gambar;?>people.png" >
OR
<img src="<?php echo $url_folder_gambar.'people.png';?>" >
Check browser code view source using ctrl+u, check the file path, and copy the source url and pasted into the borwser, whether it is rendered or not, If not there is no file in that location.
I have a problem in my wordpress theme.
The thumbnail doesn't appear on every post.
I have a website with games and every game has a thumbnail (image) . But now the image doesn't appear. When I try to see the image I get this:
Invalid src mime type:
The problematic code is:
<img src="<?php bloginfo('template_url');?>/thumb.php?src=<?=$thumb;?>&w=183&h=140&zc=1" class="thumb" alt="<?php the_title(); ?>" />
What might be wrong?
Browsing to your site I saw what the issue is. If you look at your code, it's being generated like this:
<img src="http://jocuri2k.com/wp-content/themes/Games/thumb.php?src=<?=$thumb?>... ?>
It seems that your PHP parser isn't picking up the php in the tag. Try using this instead:
<img src="http://jocuri2k.com/wp-content/themes/Games/thumb.php?src=<?php=$thumb?>... ?>
It's possible your php configuration doesn't allow for "short-tags"
<?
code here
?>
but instead require the full php tags, which are:
<?php
code here
?>
You might be able to override this in your php.ini, but if you don't have access to that, simply use the full php tags and you should be good to go.
<?php echo $thumb; ?>
I have a bit of code that, using php, I want it to call in an image rather than what it is currently calling in (which is 'echo bloginfo('name');). However, I am sadly PHP illiterate and have no idea how to do this with the 'a href' posted below. Could anyone help me call to /images/logo.png? Many thanks in advance!
<h1><?php echo bloginfo('name'); ?></h1>
The tag for add images is <img src=""> on the srcattribute you need to write the url of the image you want (in your case /images/logo.png) so, replacing the code you pasted
<h1><img src="/images/logo.png"></h1>
Take into account that the path to the image you are using now is a relative one (relative to the document requiring the image) so you probably want to have the absolute url instead.
...place at the beginning of you webpage, near the top with the rest of your PHP/JavaScript:
<?php
$image_name = '/images/logo.png';
?>
...In this are you place allof your HTML...
<img src='<?php echo $image_name; ?>'>
Basically, you can have a variable named 'image_name' that you can have be anything.
If you wanted the HREF link area to be a variable that could be changed as well, just do this:
<?php
$image_name = '/images/logo.png';
$image_url = 'http://www.google.com';
?>
Then...
<a href='<?php echo $image_url; ?>' border='0'><img src='<?php echo $image_name; ?>'></a>
What is the return of get_settings() function? ==> name's Image?
I think this code is OK, but you should check the return value of your function.