I am trying to make it so that my $content string displays the following $content .= ''.$row['content'].''; all times unless there is a video within the video portion of my database.
Then I would make it display
$content .= ''.$row['content'].'<br><br><iframe type="text/html" width="100%" height="390" src="'.$row['video'].'" frameborder="0"/>';
How can I achieve this?
If $row['video'] is null when its empty you can use this code,
if($row['video']){ //if its not NULL
$content .= ''.$row['content'].'<br><br><iframe type="text/html" width="100%" height="390" src="'.$row['video'].'" frameborder="0"/>';
}else{
$content .= ''.$row['content'].'';
}
Not sure why people like to be rude, but all the best to you buddy :)
if(isset($row['video']) && $row['video']!=""){ //if its not NULL
$content .= ''.$row['content'].'<br><br><iframe type="text/html" width="100%" height="390" src="'.$row['video'].'" frameborder="0"/>';
}else{
$content .= ''.$row['content'].'';
}
Related
I work for a voluntary fire brigade and years ago I created an operational status code using file_get_contents. Now it has no function anymore and I have no idea how to fix it.
<?php
$word = array ('T1','T2','T3','B1','B2','B3','B4','S1','S2','S3');
$word2 = array ('keine Einsätze');
$quelltext = file_get_contents("https://www.feuerwehr-huettendorf.at/einsatz.html");
foreach ($word as $einsatz) {
$pos = strpos($quelltext, $einsatz);
if($pos !== FALSE)
{
echo '<img title="Feuerwehr im Einsatz" alt="Feuerwehr im Einsatz" width="160" height="50" src="/images/content/icons/einsatz.gif" />';}
}
foreach ($word2 as $bereit) {
$pos2 = strpos($quelltext, $bereit);
if($pos2 !== FALSE)
{
echo '<img title="Einsatzbereit" alt="Einsatzbereit" width="160" height="50" src="/images/content/icons/einsatzbereit.gif" />';}
}
?>
The source code of that URL you've mentioned is (at the time of writing) simply this:
<iframe frameborder="0" style="height: 300px; width: 100%; frameborder: 0px" width="100%" height="680" src="https://www.feuerwehr-krems.at/Dokumente/Bezirk/Die%20Feuerwehren/Die%20Feuerwehren/FFInfo_Allgemein.asp?EldisID=222201&Select=1" scrolling="no"></iframe>
It doesn't contain any of the content your code is looking for. I wonder if someone changed the way the server-side application is set up.
You need to directly get the source code of the URL mentioned in that iframe instead, e.g.
$quelltext = file_get_contents("https://www.feuerwehr-krems.at/Dokumente/Bezirk/Die%20Feuerwehren/Die%20Feuerwehren/FFInfo_Allgemein.asp?EldisID=222201&Select=1");
This contains the real contents of the page.
public function main($content, array $conf) {
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$content = '';
$background_image = $this->cObj->parentRecord['data']['media'];
// Wenn ein Bild vorhanden ist
if ($background_image != '') {
$content .= '<img src="uploads/media/'.$background_image.'" alt="" title="" width="100%" />';
}
return $this->pi_wrapInBaseClass($content);
}
When expecting html I'm getting path like this:
<img src="uploads/media/1" alt="" title="" width="100%">
This is not written by me so that's why it's to understand why it behaves the way it does. Appreciate any tips.
['data']['media'] is a field used by FAL. The field itself only contains the number of references.
You need to resolve these reference with the FAL API, you may take a look here
Below is the PHP code for the images section in my website using the Cute slider plugin. I am trying to add alt text by adding text to the line $data .= '<img '.$src.''.$datasrc.''.$thumb.'>'; but the alt text ends up duplicated. Where should I add the alt text?
if($layerkey == 0) {
$src = ' src="'.$layer['properties']['image'].'"';
$datasrc = '';
}
else {
$src = ' src="'.$GLOBALS['csPluginPath'].'/img/blank.png" width="1" height="1" alt="Blank"';
$datasrc = ' data-src="'.$layer['properties']['image'].'"';
}
$data .= '<li data-delay="'.$layer['properties']['slidedelay'].'" data-src="'.$layer['properties']['slidedelay'].'" data-trans3d="'.$layer['properties']['3d_transitions'].'" data-trans2d="'.$layer['properties']['2d_transitions'].'">';
$data .= '<img '.$src.''.$datasrc.''.$thumb.'>';
The full php file is here : http://pastie.org/9167151
On this line: $src = ' src="'.$GLOBALS['csPluginPath'].'/img/blank.png" width="1" height="1" alt="Blank"'; alt is already defined, that is why you get two definitions when you try to add it in the second place. You should change the definition on that line instead of on the $data .= '<img '.$src.''.$datasrc.''.$thumb.'>'; line.
I am passing an image link from PHP to be displayed on a HTML page. But, when the page is rendered, the image does not show, instead, a place holder is shown.
PHP
$details = getimagesize($config['thumb_dir'].$value['thumbName']);
if ($details !== false){
$content.= "<h2>".$value['title']. "</h2>"."<p><img src= ".$config['thumb_dir'].$value['thumbName']." width =".$details[0]." height = ".$details[0] ." alt= ".$value['filename'] ." /></p>";
HTML output
<h2>Welcome to the Home page</h2><h2>Title for image 1</h2>
<p>
<img src= /home/rraja01/public_www/w1fma/thumbs/thumb-landscape-large.jpg width = 150 height = 150 alt= landscape-large.jpg />
</p>
Your $config['thumb_dir'] variable is returning the full path on the server and including /home/rraja01/public_www/ at the front -- very few servers have the root mapped to the website. You may need to do something like this:
$website_path = substr($config['thumb_dir'], 24);
$content.= "<h2>".$value['title']. "</h2>".'<p><img src="'.$website_path.$value['thumbName'].'" width="'.$details[0].'" height="'.$details[0].'" alt="'.$value['filename'].'" /></p>';
You have to use the relative path of your image (relative to the document root):
$details = getimagesize($config['thumb_dir'].$value['thumbName']);
$relative_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $config['thumb_dir']);
if ($details !== false) {
$content .= '<h2>'.$value['title'].'</h2>'
. '<p><img src="'.$relative_path.$value['thumbName'].'" width="'.$details[0].'" height="'.$details[0].'" alt="'.$value['filename'].'" /></p>';
}
I know i am missing something simple. I just want to display this iframe if $video-code exists. Can anyone see what is wrong with this? working in wordpress. error is on the echo line. i've also tried adding .'$video-code'. into the url.
it is displaying the iframe correctly, but the variable is displaying as text in the url. if i call the variable elsewhere in the page without the If statement, it displays correctly.
THANKS for any help!
<?php
$key = 'video-code';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
echo '<iframe id="player" width="560" height="315" frameborder="2" src="http://www.youtube.com/embed/$video-code" ></iframe>';
}?>
You can concatenate your $key, like so:
echo '<iframe id="player" width="560" height="315" frameborder="2"
src="http://www.youtube.com/embed/' . $key . '" ></iframe>';