how to remove dots in php document which contains images - php

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;
}

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>

Modify HTML page dynamically based on number of tag occurrences

I'm looking for a way to modify a HTML Document based on a number of occurring tags. For example
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
Must become:
<div>
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
<img src="" alt="" />1></a>
</div>"
...
That is, for every 4 occurencies of <img> there must be a div tag added to the page. For those of you wondering why I can't simply write this - those tags are dinamically generated via other scripts.
Furthermore, only 1 img might be present, or 1231. However, the PHP script must add <div> tag at the begginig of every first <img>and </div> on every 4th and then another <div>. If there are only 3,2 or 1 instances, then </div> must come after the last one.
Any ideas ?
Please excuse the numerous edits, I was having problem with Firefox not showing the editor.
var tags = $('tag');
var group = new Array();
var i, g = 0;
$.each(tags, function() {
if(i == 4) {
g++;
group[g] = $('<div></div>').appendTo($('body'));
}
$(this).appendTo(group[g]);
i++;
});
Or something similar to that

Preg_replace cant replace what i need

I need some help with preg_replace. At my website I need to delete some things I don't need.
Here is an example:
[caption id="attachment_100951" align="alignleft" width="448" caption="THIS IS WHAT I NEED"] [/caption]
Ok, all I need from this string is: the text inside caption="THIS TEXT",
every thing else I need to be deleted, I have used Google and tried some examples but nothing.
Maybe I need to use another function, but from what I have read on the internet this should replace .
Please help me, it's very important.
Thank you.
EDIT:
The code has some other things that i have forgot.
[caption id="attachment_100951" align="alignleft" width="448" caption="eaaaaaaaaaaaaaaaaaa"]
<a href="http://localhost/111baneease1.jpg">
<img class="size-full wp-image-100951" title="zjarr_banese1" src="http://localhost/111baneease1.jpg" alt="eeeeeeeeeeeeeeeee" width="448" height="308" />
</a>
[/caption]
So i need to get the CAPTION text and delete every thing in
[caption id="attachment_100951" align="alignleft" width="448" caption="eaaaaaaaaaaaaaaaaaa"]
but not
<a href="http://localhost/111baneease1.jpg">
<img class="size-full wp-image-100951" title="zjarr_banese1" src="http://localhost/111baneease1.jpg" alt="eeeeeeeeeeeeeeeee" width="448" height="308" />
</a>
also want delete [/caption]
too.
This regex :
$result = preg_replace('/\[caption\s+.*?caption\s*=(["\'])(.*?)\1.*?\[\/caption\]/', '$2', $subject);
will output :
THIS IS WHAT I NEED
when applied to :
[caption id="attachment_100951" align="alignleft" width="448" caption="THIS IS WHAT I NEED"] [/caption]
Updated answer based on your updated question :
$result = preg_replace('%\[caption\s+.*?caption\s*=(["\'])(.*?)\1\s*\](.*?)\[/caption\]%s', '$2\n$3', $subject);
The above regex applied to :
[caption id="attachment_100951" align="alignleft" width="448" caption="eaaaaaaaaaaaaaaaaaa"]
<a href="http://localhost/111baneease1.jpg">
<img class="size-full wp-image-100951" title="zjarr_banese1" src="http://localhost/111baneease1.jpg" alt="eeeeeeeeeeeeeeeee" width="448" height="308" />
</a>
[/caption]
Will output :
eaaaaaaaaaaaaaaaaaa
<a href="http://localhost/111baneease1.jpg">
<img class="size-full wp-image-100951" title="zjarr_banese1" src="http://localhost/111baneease1.jpg" alt="eeeeeeeeeeeeeeeee" width="448" height="308" />
</a>
I am not sure if this is exactly what you wanted. Of course you can use the regex to match and do whatever you want with groups $2 and $3...

PHP: preg_replace() - need to replace a textNode string

I have the following problem and I am not really good in regular expressions, so please, could somebody help me out?
<div class="bulletPoints">
<div>
<img src="../images/test_f01.jpg" alt="test_f01"/>1
<img src="../images/test_f02.jpg" alt="test_f02"/>2
<img src="../images/test_f03.jpg" alt="test_f03"/>3
<img src="../images/test_f04.jpg" alt="test_f04"/>4
<img src="../images/test_f05.jpg" alt="test_f05"/>5
<img src="../images/test_f06.jpg" alt="test_f06"/>6
<img src="../images/test_f07.jpg" alt="test_f07"/>7
<img src="../images/test_f08.jpg" alt="test_f08"/>8
<img src="../images/test_f09.jpg" alt="test_f09"/>9
<img src="../images/test_f09.jpg" alt="test_f09"/>10
<img src="../images/test_f09.jpg" alt="test_f09"/>11
<!-- and so on -->
</div>
</div>
I need to replace the plain text string after the image tag inside of each anchor tag. The string is always a number from 0 - 99. The IDs of the anchor tags are auto generated and the title attribute, too. I don't know how to reach only the number on all tags. I need to replace it with an empty string ''. Could somebody help me and explain how I can do that??
Thank you very very much!!
Try
preg_replace('/(<img[^>]+>)(\d+)/', "\\1", $text);
This will replace the image tag + text after the image tag with only the image tag.
you can replace />[0-9]{,2}< with /><
test with sed:
echo 'yourtext'|sed -r 's#/>[0-9]{,2}<#/><#g'
output:
<div class="bulletPoints">
<div>
<img src="../images/test_f01.jpg" alt="test_f01"/>
<img src="../images/test_f02.jpg" alt="test_f02"/>
<img src="../images/test_f03.jpg" alt="test_f03"/>
<img src="../images/test_f04.jpg" alt="test_f04"/>
<img src="../images/test_f05.jpg" alt="test_f05"/>
<img src="../images/test_f06.jpg" alt="test_f06"/>
<img src="../images/test_f07.jpg" alt="test_f07"/>
<img src="../images/test_f08.jpg" alt="test_f08"/>
<img src="../images/test_f09.jpg" alt="test_f09"/>
<img src="../images/test_f09.jpg" alt="test_f09"/>
<img src="../images/test_f09.jpg" alt="test_f09"/>
<!-- and so on -->
</div>
</div>
preg_replace('|>[0-9]{1,2}<|','><',$html);

how to insert this javascript in php

how to insert this javascript code :
thejavascript
inside img src in php
<img src="http:'.$iv[$j].'.jpg" height="220" width="200" alt="Image '.ucwords($kw).'" "thejavascript">
Thanks
You can use this jQuery script to add and onClick event in your balise img but you must adding an attribute id into your image. An id must be unique in your html page.
$("img#idImage").click(function({
window.open('welcome.html','welcome');
}));
$kw = $ucwords($kw);
"<img id='idImage' src='http:{$iv[$j]}.jpg' height='220' width='200' alt='Image {$kw}' />";
But the best will be to separate attributes height and width into a CSS stylesheet.
Insert the following HTML outside PHP brackets and it should work according to the way you posted it. I'm making a few assumptions, one being that the link you posted wraps the image code and that the PHP variables turn the image into valid code.
<a href="javascript:void(0);" onclick="window.open('welcome.html','welcome')">
<img src="http:<?=$iv[$j]; ?>.jpg" height="220" width="200" alt="Image <?=ucwords($kw); ?>">
</a>
More simple, replace "thejavascript" (with the "") by :
onclick="window.open(\'welcome.html\',\'welcome\')"
A bit different approach, onclick event is on img tag.
$javascript="window.open('welcome.html','welcome')";
$img='<img src="http:'.$iv[$j].'.jpg" height="220" width="200" onclick="'.$javascript.'">';
echo $img;

Categories