Display QR Code inside colorbox? - php

I've been able to put some code together and get a QR code to display on my site. Now I'm attempting to get the QR Code to open a larger version inside colorbox. This is the code I've got so far:
<a href="<?php echo $????; ?>" title="<?php echo $heading_title; ?>"
class="colorbox" rel="colorbox">
<img src="http://chart.apis.google.com/chart?chs=250x250&cht=qr&chld=L&chl=
<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>"
alt="Product QR Code" width="80" height="80" style="float: right" /></a>
All the code for colorbox is on this page already as I have products that use this very function. The original code said echo $popup but when I use that it shows me the main product image so that's no good. What I can't figure out is what to do with echo in the href section so it calls the image again in the pop-up box but in a larger size?
I've tried using the same url as with the img src but it only returns garbage characters in the pop-up box and doesn't know to turn it into an image instead.
Thanks for your time!

When you assign colorbox, set the photo property to true. Example:
$('a.example').colorbox({photo:true});
Colorbox normally uses a regex to determine if a link is pointing to an image or not, but the URL you are using isn't going to pass that regex.

Related

How to call a function inside img src

I have below code but don't want to encode the image as Base64 just link the image and get it with same function.
<img src="data:image/png;base64,'.base64_encode(file_get_contents(get_field('email_logo', 'option')['url'])).'" alt="The Domain" />
How to call the function inside img src?
You've not shown us how this bit of code connects to the PHP around it. Assuming that there is a closed PHP block before hand, rather than this appearing in a print or heredoc...
?>
...
<img src="data:image/png;base64,
<?php
print base64_encode(file_get_contents(
get_field('email_logo', 'option')['url']
));
?>'" alt="The Domain" />
If you want only the link and it's correct as it is:
<img src="'.get_field('email_logo', 'option')['url'].'"/>

Joomla 3.7.1 - Adding Links and title tags to article intro images

Hi guys wondering how I can manually add a link from Joomla intro article images to their corresponding article and also add a title tag to the link.
Ideally the way I want to do this is to for example wrap an achor tag around the image reference in the blog-item.php file (also want to achieve this for generic articles). And then within the anchor tag capture the related image alt tag and populate the title tag with that value.
Below is where I'm at. It's not currently working, not sure why as it should be pretty straight forward. I'm not a php developer, wondering what i'm missing.
Also already cleared both browser and joomla caches after my changes.
Any help would be appreciated, cheers guys
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>" title="<?php echo htmlspecialchars($images->image_intro_alt); ?>">
<img
src="<?php echo htmlspecialchars($images->image_intro); ?>"
alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
</a>
To make your code work, add just before your code.
<?php $images = json_decode($this->item->images); ?>
and your code will start working.
Already tested and it worked.

Echo a txt file in data-caption

I am trying to echo in php the image description in the data-caption of the clearing image gallery of Foundation3 but it is not working. Here is my code:
<li class="clearing-feature">
<a href="administration/galleri/kcfinder/upload/images/Galleri1/1.jpg">
<img data-caption="<?php echo $myDataBild1 ?>;" src="kcfinder/upload/images/Galleri1/1.jpg"></a>
</li>
This is not working. The image gallery is still working correctly but the caption in this picture is not showing. How can I correct this?
NOTE: The php $myDataBild1 is a txt file with text inserted via CKEditor and it is working just fine. Let me know if you need the code and the variable is shown if I echo it anywhere else.
Misplaced comma - also try by using addslashes.
<img data-caption="<?php echo addslashes($myDataBild1); ?>" src="kcfinder/upload/images/Galleri1/1.jpg"></a>

Evaluating PHP inside javascript for a wordpress blog for a pinterest button

This is a very interesting problem that I am running into. I am appending a div with a pinterest button using javaScript but I am using PHP inside the Javascript to determine what the source of the image and the URL of the page to send to pinterest.
I am doing it this way instead of using plain HTML provided by pinterest because I have found that you can use your own branded pinterst button .jpg instead of the iFrame that pinterest uses and forces you to use their branding. I have used this javaScript successfully on other parts of my sites without using PHP. I am very new to PHP and JavaScript so I am not sure if I am missing anything but I have spent countless hours tinkering with this problem and need a fresh set of eyes. Thanks for all your help!
function add_social_media () {
?>
<p align="right">
<a href="http://twitter.com/home?status=<?php print(urlencode(get_permalink())); ?>+<?php print(urlencode(the_title())); ?>">
<img src="/sites/aerialist.localhost/files/images/twitter.jpg" alt="Share On Twitter" /></a>
<a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Ffamousartistprints.com%2F&media=http%3A%2F%2Ffamousartistprints.com%2F" ><img border="0" src="/sites/aerialist.localhost/files/images/twitter.jpg"/></a>
<script>
jQuery(document).ready(function() {
jQuery('#pinItDiv').append( '<a class="pin-it-button" href="http://pinterest.com/pin/create/button/?url='+
<?php the_permalink(); ?>+
'&media='+
//set your image path here
<?php if(function_exists('the_post_thumbnail')) echo wp_get_attachment_url(get_post_thumbnail_id()); ?>+
'&description='+<?php echo get_the_title(); ?>'">'+
'<img class="pinItSuite" title="Pin It" src="/sites/aerialist.localhost/files/images/pinSuite.jpg" alt="" border="0" /></a>');
});
</script>
<?php
}
add_action('thesis_hook_before_headline', 'add_social_media');
As I understand it, it's best practice to keep php and javascript separate as much as possible. Try putting your javascript in its own js file and enqueuing it with wordpress's scripts via wp_enqueue_scripts. Then use wp_localize_script to pass it any php variables you need (such as the_permalink() or get_the_title() ).
Check out these sites for more info:
http://wp.tutsplus.com/articles/how-to-include-javascript-and-css-in-your-wordpress-themes-and-plugins/
http://tosbourn.com/2011/08/wordpress/accessing-php-variables-from-within-javascript-under-wordpress/

A href tag is not working

Strange thing happens, I have this code, on my wordpress site:
<a href="www.google.com" target="_self" class="facebook" ><img src="<?php echo get_template_directory_uri(); ?>/images/facebook.png"/></a>
The image is loaded, but is not clickable, I mean nothing happens when I click on it, what's wrong?
The link to my page is: http://toibz.com/ibz. Click on the "facebook" logo in the lower right corner.
add http:// to your link like:
<a href="http://www.google.com"..
Set position:fixed on the a tag instead of floating it.

Categories