Basically, trying to modify a theme to suit. I've got a PHP function that I can't seem to modify appropriately to stop it from creating a hand cursor when hovering as well as stopping it from opening the image as a lightbox style gallery when clicked. I am trying to basically make it do absolutely nothing, but have the viewer scroll through the images.
<?php
$project1Images = explode( ',', $project1Images );
$project1ImagesLinks = explode( ',', $project1ImagesLinks );
for ($i=0; $i < count($project1Images); $i++) {
$thumb_id = CoSy_getImageId($project1Images[$i]);
$thumb_obj = wp_get_attachment_image_src($thumb_id, 'full');
$thumb_width = $thumb_obj[1];
$thumb_height = $thumb_obj[2];
echo '<a href="'. esc_url($project1ImagesLinks[$i]) .'" rel="gallery">';
echo '<img class="lazy" data-original="'. esc_url($project1Images[$i]) .'" alt="" data-width="'. esc_attr($thumb_width) .'" data-height="'. esc_attr($thumb_height) .'" >';
echo '</a>';
}
?>
Thanks in advance!!
P.s. - I have a good understanding of reading code, but am not a coder by any means.
Thanks.
To remove hand cursor when hovering and stopping it from opening the image as a lightbox you need to remove
echo '<a href="'. esc_url($project1ImagesLinks[$i]) .'" rel="gallery">';
and
echo '</a>';
Related
I'm doing a PHP assignment having a very basic knowledge of PHP.
I'm looping through a list of pictures from S3, but after looping through I want a selected picture to be opened on click. I'm clueless on how it will proceed further.
I have a product.php page which has to redirect to single .php.
PHP is server side language that send html tags to render in browser side, so you can use client side languages (exp: javascript) to handle it.
You can do it with HTML: Anchors aka Links:
$images = [
'a.jpg',
'b.jpg'
];
echo '<ul>';
foreach($images as $image) {
echo '<li>';
echo '<a href="single.php?image=' . $image . '">';
// small preview-images could be prefixed with 'thumb_' . $image
echo '<img src="' . $image . '" width='100'/>';
echo '</a>';
echo '</li>';
}
echo '</ul>';
In single.php you will get the clicked Image with $_GET['image']
I am trying to make a thumbnail image clickable so that when clicked, it shows the full size image, but I keep getting a PHP error and I'm not sure why. This is a Wordpress site. I suspect it has something to do with the variable that's inside the URL, but I need some guidance. I've searched stack for almost 8 hours now...Here is my code:
if ( has_post_thumbnail() ) {
echo '<a href="'get_the_post_thumbnail_url($post_id, 'full');'">';
the_post_thumbnail('cb-thumb-600-crop');
echo '</a>';
} else {
I think what's wrong on your code is this:
echo '<a href="'get_the_post_thumbnail_url($post_id, 'full');'">';
should be:
echo '<a href="' . get_the_post_thumbnail_url($post_id, 'full') . '">';
Try This:
if ( has_post_thumbnail() ) {
$anything=get_the_post_thumbnail_url($post_id, 'full');
$anythings=the_post_thumbnail('cb-thumb-600-crop');
echo ''.$anythings.'';
} else {
The problem is on this line:
echo '<a href="'get_the_post_thumbnail_url($post_id, 'full');'">';
You forgot the dots between the single quotes near "get_" and ");"
It should look something like this:
echo '<a href="' . get_the_post_thumbnail_url($post_id, 'full') . '">';
Good luck and keep coding! :)
How can I go about convering a public instagram URL into JSON using PHP? Ex: https://www.instagram.com/explore/tags/brindle/
I can't use the API as I need public hashtag content and my use case won't qualify for their app review process :-(.
Here is what I have so far but it does not pull all images. Also, I'd like to be able to load the "load more" images as well. Any help would be much appreciated!
$instagram_source = file_get_contents("https://www.instagram.com/explore/tags/brindle/");
$instagram_data = explode("window._sharedData = ", $instagram_source);
$instagram_json = explode(';</script>', $instagram_data[1]);
$instagram_array = json_decode($instagram_json[0], TRUE);
$instagram_media = $instagram_array['entry_data']['TagPage'][0]['tag']['media']['nodes'];
if(!empty($instagram_media)) {
echo '<ul>';
foreach($instagram_media as $im) {
echo '<li>';
echo '<a href="https://www.instagram.com/p/'.$im['code'].'/" target="_blank">';
echo '<img src="'.$im["display_src"].'" alt="" width="'.$im["dimensions"]["width"].'" height="'.$im["dimensions"]["height"].'" />';
echo '</a>';
echo '</li>';
}
echo '</ul>';
}
Take a look at this solution here: https://github.com/Bolandish/Instagram-Grabber
Thats the best one i know until now.
I'm trying to remove the "img src" tag from the php so it'll simply display the images url, rather than displaying the actual image. This is the code I've got so far and it works perfectly, but when it's rendered it shows thumbnails instead of urls.
<?php $pics = get_post_meta( $post->ID, 'pics', true );
foreach( $pics as $pics)
{
$image_attributes = wp_get_attachment_image_src( $pics['pictures'] );
echo '<img src="' . $image_attributes[0] . '" />';
}
?>
I know theres a way to do this, but I don't know how to remove the tags without breaking the image code. Any help is appreciated.
If you just want to echo the image src and not display it as an image then change
echo '<img src="' . $image_attributes[0] . '" />';
to
echo $image_attributes[0];
<?php
$pics = get_post_meta( $post->ID, 'pics', true );
foreach( $pics as $pics)
{
$image_attributes = wp_get_attachment_image_src( $pics['pictures'] );
echo $image_attributes[0];
}
?>
So do you want to show on the page the "html code" with the tag and the src attribute?
Have you tried to enclose "img" tag within "pre" tag?
echo '<pre><img src="' . $image_attributes[0] . '" /></pre>';
<?php
$i = 0;
$page = get_the_content();
$doc=new DOMDocument();
$doc->loadHTML($page);
$xml=simplexml_import_dom($doc);
$images=$xml->xpath('//img');
foreach ($images as $img) {
list($width, $height, $type, $attr) = getimagesize($img['src']);
if ($height > 149 ) {
echo '<img src="' . $img['src'] . '" alt=" ' . $img['alt'] . ' - funny and hot pictures" title=" ' . $img['title'] . ' - funny fail picture dump" onerror=\'this.style.display="none" \'><br>';
$i++;
if ($i == 3 ) { break;}
}
else
{
// don't display
}
}
?>
I replaced the "<?php the_content(); ?>" piece of code with the one above. It's supposed to strip out all of the text in my post and just leave the images which it does nicely. But when I embed a video the php breaks. How would I allow posts to show youtube videos?
You should look into using custom fields:
http://codex.wordpress.org/Custom_Fields
There is a great plugin that creates good admin control panels for them too:
http://wordpress.org/extend/plugins/advanced-custom-fields/
You could use a custom field to specifically put a video into the page.
Is there a particular reason you want to strip the text out of the post? - e.g. could you just not put text in the post at all? - or could the text be put into the excerpt instead, or into a custom field so that you don't have to over complicate the output code?