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
Related
This seems like a really simple issue, but I'm not having any luck solving it and not entirely sure what to search. I am trying to get $logo to be used by the funciton, so that the image uses the variable defined on line 1:
$logo = 'http://dev.batman.com/logo.png';
function signup_email_body( $logo ){
$body = '<img src="'.$logo.'" />';
}
The funciton is then triggered on signup and the src attribute is missing.
(n.b. the above is simplified code to save masses of HTML)
The value of $body is never returned from your function so it essentially goes away once the function call is finished executing. You need to return that value from your function in order to actually use it:
$logo = 'http://dev.batman.com/logo.png';
function signup_email_body( $logo ){
return '<img src="'.$logo.'" />';
}
$body = signup_email_body( $logo ); // <-- now $body has that string value
Using sprintf() is a neat idea in these cases.
$logo = 'http://dev.batman.com/logo.png';
function signup_email_body($logo)
{
return sprintf('<img src="%s" />', $logo);
}
echo signup_email_body($logo);
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'].'';
}
I didn't expect this to be difficult but so far have failed at implementing it.
Simply I want to add a class name to the link tag that wraps the img tag when you insert an image into a post using the media library.
I want to turn this
<img src="http://..." alt="..." width="780" height="490" class="alignnone size-full wp-image-12" />
Into this
<img src="http://..." alt="..." width="780" height="490" class="alignnone size-full wp-image-12" />
I can do it simply enough using jQuery, but I'd much prefer to use a wordpress filter or custom function. SO the output in the post includes the class name.
Thanks msbodetti, the solution is as follows.
function add_colorbox_class_to_image_links($html, $attachment_id, $attachment) {
$linkptrn = "/<a[^>]*>/";
$found = preg_match($linkptrn, $html, $a_elem);
// If no link, do nothing
if($found <= 0) return $html;
$a_elem = $a_elem[0];
// Check to see if the link is to an uploaded image
$is_attachment_link = strstr($a_elem, "wp-content/uploads/");
// If link is to external resource, do nothing
if($is_attachment_link === FALSE) return $html;
if(strstr($a_elem, "class=\"") !== FALSE){
// If link already has class defined inject it to attribute
$a_elem_new = str_replace("class=\"", "class=\"fancylink ", $a_elem);
$html = str_replace($a_elem, $a_elem_new, $html);
}else{ // If no class defined, just add class attribute
$html = str_replace("<a ", "<a class=\"fancylink \" data-fancybox-group=\"gallery\" ", $html);
}
return $html;
}
add_filter('image_send_to_editor', 'add_colorbox_class_to_image_links', 10, 3);
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 trying to insert a link in an echoed line,
regular links work, but not this one, cant figure it out what's wrong
if($gallery_images != ''){
foreach ($gallery_images as $gallery_image){
$thumb = wp_get_attachment_image_src($gallery_image[SN.'gallery_post_image']['id'], 'post-thumb', false);
echo '<li><a <img src="'.$thumb[0].'" alt="'.$gallery_image[SN.'gallery_post_title'].'" /><p class="flex-caption">'.$gallery_image[SN.'gallery_post_title'].'</p></li>';
}
}
the_permalink() is a not a return function, it echoes the permalink. Replace it with get_permalink, which returns the permalink.
if($gallery_images != ''){
foreach ($gallery_images as $gallery_image){
$thumb = wp_get_attachment_image_src($gallery_image[SN.'gallery_post_image']['id'], 'post-thumb', false);
echo '<li><a <img src="'.$thumb[0].'" alt="'.$gallery_image[SN.'gallery_post_title'].'" /><p class="flex-caption">'.$gallery_image[SN.'gallery_post_title'].'</p></li>';
}
}
Your first problem is that. You don't include a function on a string that way.
echo '<li><a href="**<?php the_permalink(); ?>**">
Try this:
echo '<li><a href="'.the_permalink().'">
Then
.$gallery_image[SN.'gallery_post_title'].
You got a syntax error there.
SN.'gallery_post_title' // notice SN
It's fine if you define SN though.
Also, why do you have a close curly brace }?
Did you just copy and paste your code here sloppily or is that intentional? It's confusing if it is.