Insert viber link to email template - php

There is email template with html:
<tr style="display: inline-block;margin-right: 10px;">
<th title="Viber" style="width:32px;vertical-align:middle">
<a href="viber://chat?number=%2bPhoneNumber" style="Margin:0;color:#ff7878;font-weight:400;margin:0;padding:0;text-align:left;text-decoration:none" target="_blank">
<img src="<?= $_SERVER['SERVER_NAME'] . '/img/viber.png' ?>" width="32" height="32" border="0" style="border:none;display:block;margin:0 auto;max-width:32px" class="CToWUd">
</a>
</th>
</tr>
Received email (Thunderbird, Outlook...etc) have not a link to viber chat. Only image. Mail send by php Mailer (YII2)
But letter with href http://...... contains link and is clickable

Related

ACF - Display Multiple Repeater Images

My end goal is to create a gallery of Images that when clicked link to an external website. This needs to be done through Advanced Custom Fields, so I made a repeater that has the image and link in the same row:
link1 | cover_image1
link2 | cover_image2
Right now I'm inserting this code into a text editor inside my webpage. I also imported some short-code from here, that allows me to use %ROW% as an iterator.
"attachments" is the parent repeater and "link" and "cover_image" are the children.
[acf_repeater field="attachments"]
external url = [acf field ='attachments_%ROW%_link']
image url = [acf field ='attachments_%ROW%_cover_image']
<a href =[acf field ='attachments_%ROW%_link'] >
<img src = [acf field ='attachments_%ROW%_cover_image'] width="300" height="214" />
</a>
[/acf_repeater]
The webpage renders this:
Where the broken image contains this code:
<img src="[acf" field="attachments_0_cover_image" ]="" width="300" height="214">
I think [acf field ='attachments_%ROW%_cover_image'] in <img> isn't resolving all the way to the url, as external url = and image url = both render the correct urls.
Wordpress also converts my code to this after saving, so its probably a syntax error?
[acf_repeater field="attachments"]
external url = [acf field = attachments_%ROW%_link]
image url = [acf field = attachments_%ROW%_cover_image]
<a href="[acf">
<img src="[acf" width="300" height="214" />
</a>
[/acf_repeater]
I'm not sure how to properly convert [acf field ='attachments_%ROW%_cover_image'] to a url in the <img> and I could use some help on the proper syntax. Thank you so much for you help!
html for the attribute per Arian:
<div class="fl-module fl-module-rich-text fl-node-5d4926759d7aa"
data-node="5d4926759d7aa">
<div class="fl-module-content fl-node-content">
<div class="fl-rich-text">
<p>Agenda: https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/cute-cat-photos-1593441022.jpg?crop=0.669xw:1.00xh;0.166xw,0&resize=640:*</p>
<p>Video Links: </p>
<p>Thumbnails: </p>
<p></p>
<p>external url = https://www.youtube.com/watch?v=uHKfrz65KSU<br>
image url = http://wordpress.local/wp-content/uploads/Thumbnail_1.png</p>
<p><a href="[acf" field="attachments_0_link" ]=""><br>
<img src="[acf" field="attachments_0_cover_image" ]="" width="300" height="214"><br>
</a></p>
<p><br></p>
<p>external url = https://www.youtube.com/watch?v=X2lIovmNsUY<br>
image url = http://wordpress.local/wp-content/uploads/Thumbnail_2-1.png</p>
<p><a href="[acf" field="attachments_1_link" ]=""><br>
<img src="[acf" field="attachments_1_cover_image" ]="" width="300" height="214"><br>
</a></p>
<p><br></p>
<p>external url = https://www.youtube.com/watch?v=hDJkFLnmFHU<br>
image url = http://wordpress.local/wp-content/uploads/Thumbnail_3-1.png</p>
<p><a href="[acf" field="attachments_2_link" ]=""><br>
<img src="[acf" field="attachments_2_cover_image" ]="" width="300" height="214"><br>
</a></p>
<p><br></p>
</div>
</div>
</div>
Not a wordpress guy, but seems like wordpress prevents expanding/executing shortcodes with parameters within html attributes, maybe this could work as workaround if you can put php code there:
<?php
$link = do_shortcode("[acf field ='attachments_%ROW%_link']");
$cover_img = do_shortcode("[acf field ='attachments_%ROW%_cover_image']");
?>
<a href="<?= $link ?>">
<img src="<?= $cover_img ?>" width="300" height="214" />
</a>
Actually i found comment on this:
It appears it's using the same quotes for the HTML attribute and the shortcode's attributes that create problems.
at here
so this may work too:
<a href="[acf field ='attachments_%ROW%_link']">
<img src="[acf field ='attachments_%ROW%_cover_image']" width="300" height="214" />
</a>
or without shortcode quotes:
<a href="[acf field=attachments_%ROW%_link]">
<img src="[acf field=attachments_%ROW%_cover_image]" width="300" height="214" />
</a>
last option i can think of is creating parameter-less shortcodes like this:
function acflink_shortcode() {
return do_shortcode("[acf field ='attachments_%ROW%_link']");
}
add_shortcode('acflink', 'acflink_shortcode');
function acfimage_shortcode() {
return do_shortcode("[acf field ='attachments_%ROW%_cover_image']");
}
add_shortcode('acfimage', 'acfimage_shortcode');
then using in editor like:
<a href="[acflink]">
<img src="[acfimage]" width="300" height="214" />
</a>

php codeigniter cannot access file pdf in hosting

I can access my file and work correctly in localhost, but problem starts when I move it to the host.
This is my code:
Show My Pdf
I try this and have the same problem:
<embed src="<?php echo base_url();?>uploads/syarat/<?php echo $username.'/'.$namafile;?>" type="application/pdf" width="100%" height="
When I access directly, the server does not respond.
actually i can access easyly with google viewer
<div class="col-xs-12">
<div class="row">
<i class="ace-icon glyphicon glyphicon-plus"></i> Buka Di Tab Baru
</div><br/>
<object id="pdf" data="<?php echo base_url();?>uploads/syarat/<?php echo $username.'/'.$namafile;?>" type="application/pdf" width="100%" height="600px" />

viewing an image recieved from database in form of an blob datatype to a new page in php

I have made an code which is used to receive image from database and it's working perfectly. But now as user click's on the image it should be opened on a new page,and i have tried few thing but it's not working...
the below code id used to display the image
$query=mysqli_query($conn,"select * from images") or die("unable to
connect");
$i=1;
while($row=mysqli_fetch_array($query,MYSQLI_BOTH))
{
//echo '<img id="my" height="150" width="320" src="data:image;base64,'.$row['image'].' "> ';
echo '
<tr>
<t>'.#$row["id"].'</td>
<a target="_blank" href="09.jpg">
<img height="150" width="150" src="data:image/jpeg;base64,'.base64_encode( $row['image'] ).'"/>
<td>x</td>
</td>
';
$i++;
}
?>
Now here i want is when user click's on the image , a new page will show an enlarged image...
Don’t save image in database, save it as file in server then save the file name into database
You must be save image as two sizes, small and normal, the smal for display in table, when the user click on image, go to normal image
You can save one name in database, example (img1.jpg)
And in images directory save (sm-img1.jpg) and (img1.jpg)
The code
<a href="url/mydirectory/$row['image']" target="_blank">
<img width="150" height="150" src="url/mydirectory/sm-$row['image']" />
</a>
Or
<img width="150" height="150" src="url/mydirectory/sm-$row['image']" onclick="window.open('url/mydirectory/$row['image']', '_blank');" />

how to remove dots in php document which contains images

I would love to remove the Dots as you can see in the image Please Help
The Below is my code
<body>
<h1>Please Check Your Email For Verfication that you are not a Bot :-) </h1>
<a href='hotmail.com' class="icon" ><img src="outlook.png" width="70px" height="70px"/></a><br>;
<img src="Gmail.png" width="70px" height="70px"/><br>;
<img src="yahoo.png" width="70px" height="70px"/><br>;
</body>`
Perhaps removing the semi-colons could help:
<body>
<h1>Please Check Your Email For Verfication that you are not a Bot :-) </h1>
<a href='hotmail.com' class="icon" ><img src="outlook.png" width="70px" height="70px"/></a><br>
<img src="Gmail.png" width="70px" height="70px"/><br>
<img src="yahoo.png" width="70px" height="70px"/><br>
</body>
No need for the semicolons at the end of your lines, see below:
<body>
<h1>Please Check Your Email For Verfication that you are not a Bot :-)</h1>
<a href='hotmail.com' class="icon" ><img src="outlook.png" width="70px" height="70px"/></a><br>
<img src="Gmail.png" width="70px" height="70px"/><br>
<img src="yahoo.png" width="70px" height="70px"/><br>
</body>
If you'd like to review HTML syntax, this site is a great resource: HTML5 Syntax
So you have a few issues that are causing extra symbols to appear, and the links won't work as you'd expect.
The semi-colons are showing up because you have semi-colons after each <br/> which don't need to be there.
The underscores after each image are appearing because the images are nested in anchor tags. Anchor tags by default have an underline text decoration, and images have a small bit of extra sizing in most cases.
In anchor tags on almost all webservers, if you don't define a protocol (like http://) to use, then it will send the user to http://yoursite.com/<current_page>/<clicked_link> rather than the external website that you'd expect.
Using these should fix all of that:
HTML
<body>
<h1>Please Check Your Email For Verfication that you are not a Bot :-) </h1>
<a href="http://hotmail.com" class="icon" ><img src="outlook.png" width="70px" height="70px"/></a><br>
<img src="Gmail.png" width="70px" height="70px"/><br>
<img src="yahoo.png" width="70px" height="70px"/><br>
</body>
CSS
.icon {
text-decoration: none;
}

Regex to replace url in html page

i have an html page
<tr>
<td rowspan="7">
<a href="http://www.link1.com/" style="text-decoration: none;">
<img src="image1.jpg" width="34" height="873" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.link1.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.url.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
I want to replace all url in href by mytest.com?url=$link
I try with :
$messaget = preg_replace('/<a(.*)href="([^"]*)"(.*)>/','mytest.com?url=$2',$messaget);
This may help you in the short run:
preg_replace('/<a (.*)href=[\'"]([^"]*)[\'"](.*)>/', '<a $1href="mytest.com?url=$2"$3>', $messaget);
In your regex you were using href="...", that is, double quotes, but in your HTML you have a mixture of both double and single quotes.
And in the replacement string you forgot to include $1 and $3.
That said, DO NOT use regex to parse HTML. The answer by #BenLanc below is better, use that instead. Read the link he posted.
Don't use regex on HTML, HTML is not regular.
Assuming your markup is valid (and if it's not, pass it through Tidy first), you should use xpath, to grab the elements and then update the href directly. For example:
<?php
$messaget = <<<XML
<tr>
<td rowspan="7">
<a href="http://www.link1.com/" style="text-decoration: none;">
<img src="image1.jpg" width="34" height="873" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.link1.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
<td colspan="2" rowspan="2">
<a href='http://www.url.com/test.php?c=1'>
<img src="image1.jpg" width="287" height="146" alt="" style="display:block;border:none" />
</a>
</td>
</tr>
XML;
$xml = new SimpleXMLElement($messaget);
// Select all "a" tags with href attributes
$links = $xml->xpath("//a[#href]");
// Loop through the links and update the href, don't forget to url encode the original!
foreach($links as $link)
{
$link["href"] = sprintf("mytest.com/?url=%s", urlencode($link['href']));
}
// Return your HTML with transformed hrefs!
$messaget = $xml->asXml();
Don't forget /m at the end of your regexp since your are using multiline source:
PHP Doc PCRE
Regex to match an url:
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
More background info

Categories