I am fairly new to the code world and am trying to display an image inside of an echo string.
Here is the code
<?php
echo String::insert(
__("Are you owner of this listing? :claim_link"),
array('claim_link'=>$html->link(
__("CLAIM IT NOW"),
array("controller"=>"listing_claims",
"action"=>"claim",$listingData['Listing']['id']
)
)
))
?></div>
The code works fine, however, I want to replace ... (__("CLAIM IT NOW") ... with an image instead of just text...something like 'img src='my-image.png'. The goal is to get a button to appear instead of text.
so far, when I make the change, I see whatever text I have typed in.
Any help is appreciated.
Replace:
"CLAIM IT NOW"
with:
"<img src='yourimage.png' alt='Image'>"
If you are using CakePHP you should do something like:
$html->link($html->image('yourimage.png', ...
Related
I'm trying to get a field in the customizer for inserting the link to the LinkedIn profiles of my customer.
Before I made a text field and used the wpautop function. That works very well. Does anybody know a quick way to let the user insert a plain link like example.com what will be displayed like https://example.com?
With a page _blank please :-)
For my text i used this code:
<?php echo wpautop (get_theme_mod('themename-expression-text') )?>
I guess i'll need something like:
<?php echo wpautoahref (get_theme_mod('themename-expression-text'))?>
I just can't find it :-)
Fixed it! Definitely to deep into the code today :-)
<a target="_blank" href="<?php echo (get_theme_mod('themename-example-externallink') )?>">Linkedin</a>
I have a very simple php script, of which is made to read the content of a file and then print it out on the site, using the method "readfile();" Here below you can see my code.
<?php
$readThisFile = './myFile.txt';
readfile($readThisFile);
?>
Now my question is whether it is possible to change the color of the text outcome, of which is visible on the website page. To give an example, once the php method has run and read my file and it outputs "hello world" on the site, because that is whats inside. Then the output is in black like any regular text, I was wondering whether it is possible to change that outcome to white or alike so that it is "invisible" on a white page.
I have seen it is possible to do this if the content which is on the site is "echoed" and not "read" like below here.
<?php
echo '<span style="color:white; align:center;">Hello World!</span>';
?>
But if that is possible to do with "readfile();" as well, I am not completely sure how I would implement it.
You can always do this:
<?php
$readThisFile = './myFile.txt';
echo `<span style="color:white; align:center;">`
readfile($readThisFile);
echo '</span>';
?>
Put the read text inside other element :)
I have PHP code that generates HTML code which makes a grid of images. The images are taken from links that are generated for each new image, I also add 133x100 at the end of the image link to resize it on the page. My problem is that a seemingly random selection of images won't display, and I just get a broken image symbol. For example:
This is a link to an image that is generated on my page and is displayed.
This is a link to an image that will not be displayed.
I am only allowed to post 2 links, but removing the %20.%20/133x100 from the end of the last link will show what the picture should be.
Here is the part of the code for the image source:
function display_images(){
//This cycles through each image and displays it as HTML
while($row = $item->fetch()){
Echo "`<img src= '$link[Image_Link] . /133x100' />`"
}
}
It is then called here in a class which puts the images in a grid:
<ul class="rig columns-4">
<?php
display_images();
?>
</ul>
Seemingly about every 2/20 images won't work, and seeing all the links are in the same format, I don't understand why they won't work, and it just seems random.
EDIT: I have noticed that the links that work have 62fx62f at the end of them before the added %20.%20/133x100. If I add it to the raw link in the right place, it makes the image work. But using that generated link, the image still won't load on the page. So using a link with a working image will not work on the page. (This is the same with the raw link without %20.%20/133x100, that links to an image but also won't work on the website)
When visiting the links, the urls look like this:
http://www.example.com/image/randomcharacters%20.%20/133x100
The links work without the %20.%20 at the right dimensions, like so:
http://www.example.com/image/randomcharacters/133x100
This leads me to believe that it may work if you try using the following for the image source instead:
<img src= '$link[Image_Link]/133x100' />
The full code would look like this, for the while function:
while($row = $item->fetch()){
echo "<img src= '" . $link['Image_Link'] . "/133x100' />";
}
I am not aware of steamcommunity much but from the looks of it, i think you should try this.
Instead of putting
. /133x100
Use
/133fx100f
So your URLs would be
while($row = $item->fetch()){
echo "<img src= '" . $link['Image_Link'] . "/133fx100f' />";
}
Just did some trial and error and found out. No explanations for this though!!
i have one product which has two images.
(1)image-1(originle image)
(2)image-2
now images are showing in product details page but now i want customize that i want to write on image-1 put some text like original image
i have tried like skin_url, getMediaGalleryImages()
echo $_helper->productAttribute($_product, $_img, 'image');
echo $_product->getMediaGalleryImages()->getItemByColumnValue('label', 'LABEL_NAME');
but not working
i want to how to get first image name of product??
Try this one:
echo $_product->getImageUrl();
If you need the Image-Name, you have many possibilties, like explode or regex ...
__
Edit:
You can try your method, too, just add a "->getUrl();"
$_product->getMediaGalleryImages()->getItemByColumnValue('label', 'LABEL_NAME')->getUrl();
If this is also "not working", maybe you could give us a little hint, what "not working" actually means, is there an error or a result, which you don't want ...
Thanks!
The table cell in the below code is being used as part of a messaging system and it returns the url as a link to the attached file to the message.
echo '<td width="25%">'.wp_get_attachment_url($row->file_attached).'</td>';
This is fine and works well, my problem is that I would like it to either only show the title of the file ( not the full url)
or even better would be to have it print "file attached" as a link, but if there is no file to get could it say "no file attached"
I am a complete novice at this and I am trying to stuble my way through. It would be great if somebody could push me in the right direction.
Thanks
If you just mean you want the text of the link to be different, this is really basic HTML (not PHP):
some text for the link
In your case, you have the URL repeated as the contents of the <a> tag, but you can put whatever you want there.
Edit: To only show the link if there is a link to show, you need an if statement, probably the simplest piece of programming logic there is:
if ( $row->file_attached ) {
// echo a link
}
else {
// echo something other than a link
}
Try following. when attachement is found it displays your link, when its not found it just shows a message. It is not a good idea to have a link when no attachement is found, that will link to nowhere...
if(wp_get_attachment_url($row->file_attached))
echo '<td width="25%">'.sometext.'</td>';
else
echo '<td width="25%">no file attached</td>';