how can I get the URL of feature image in RSS feed - php

I have a URL of my RSS feed website and I want to access to the details in this URL in another website but I have some issue!
I can get the title and the link is this Feed but I cant get the feature image and I DONT know how to code it !
feature image is in the <description> tag but I DONT know how to get it !
here is my code :
$rss_feed = simplexml_load_file("https://asphaltshop.ir/product-category/hoodie/feed");
if(!empty($rss_feed)) {
$i=0;
foreach ($rss_feed->channel->item as $feed_item) {
if($i>=10) break;
?>
<div> <img src="<?php echo $feed_item->description; ?>"> <a class="feed_title" href="<?php echo $feed_item->link; ?>"><?php echo $feed_item->title; ?></a></div>
<?php
$i++;
}}
}
and here is my URL of RSS feed :
https://asphaltshop.ir/product-category/hoodie/feed
please someone tell me how can I get the image with changing this code!

Related

How to link thumbnail image to a large image

I'm trying to create a simple image gallery that displays thumbnails of uploaded images. Once a thumbnail is clicked, I would like to be directed to a page with the large version of the image, along with a comment section. So basically I'm trying to do something similar to deviantart. What I have now looks something like this:
<a href="<?php echo $image->large_image_path; ?>">
<img src="<?php echo $image->thumbnail_image_path; ?>"></a>
Clicking on a thumbnail will take to me to the large image path, which is not really what I want. Any help is greatly appreciated.
You must make the href="<?php echo $image->large_image_path; ?>" to somehing like href="show_image.php?image_path=<?php echo $image->large_image_path; ?>"
In show_image.php you can den get the path of the image by $_REQUEST['image_path'], and add it into the code like this:
<img src="<?php echo $_REQUEST['image_path']; ?> />
The you can add information or styling around the bigger image.
So, link to a PHP page instead of the image. Even better, put the image path in to a database, and use the image id to get the path and information of the image. Like this:
href="show_image.php?image_id=<?php echo $image->id; ?>"> and then in show_image.php, given that you have a method for getting the image:
<?php $image = GetImage($_REQUEST['image_id']); ?>
<img src="<?php echo $image->large_image_path; ?> />
<?php echo $image->description; ?>
<?php echo $image->date; ?>
Hope this helps you on the way.

What is the php code I need to add to this file in order to get an image to appear in this custom post type?

I am using a wordpress theme that has a custom post type called "link" which simply produces a post where the title links to an outside link you specify. It also includes some text in the body of the post. I would like to also be able to display an image. Right now it is not showing the image.
Here is the code:
elseif ( has_post_format( 'link' )) {
if(get_post_meta($post->ID, '_format_link_url', true)!=''){
$link = get_post_meta($post->ID, '_format_link_url', true);
}else{
$link = '';
}
?>
<h2 class="entry-title">
<a href="<?php echo $link; ?>" target="_blank" title="Follow this link">
<?php the_title(); ?>
</a>
</h2>
<p>
Is there anything I can add to make it display an image as well as text?
Thanks!
I can't see anywhere on this example where you are using an tag to insert an image. The img tag has two required attributes, src and alt. Src is the path to your image, whereas alt is the alternate text for the image. So:
<img src="images/myImage.png" alt="This Is My Image"/>
Hope that helps!

Google+ Plus API Define a specific image variable

I am trying to integrate the Google+ API on my website so that when a user submits approval via Oauth their Google+ activity feed will be displayed.
I have all of it working pretty much and am working on defining the variables that it will display for their feed.
Currently, this is what I have that IS working:
$activityMarkup = '';
foreach($activities['items'] as $activity) {
$url = filter_var($activity['url'], FILTER_VALIDATE_URL);
$title = filter_var($activity['title'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$content = filter_var($activity['object']['content'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$published = $activity['published'];
$totalItems = $activity['object']['plusoners']['totalItems'];
$activityMarkup .= "<div class='activity'>
<a href='".$url."' target='_blank'>$title</a>
<div>$content</div>
<div><br/><span>Date Published: </span>$published</div>
<div><br/><span>Total Likes: </span>$totalItems</div>
</div><br/><br>";
What I am trying to get to work is adding in the image that is associated with the post, namely the thumbnail.
I have tried different variations based on using existing code that works, but I just can't figure it out.
According to the Google API, this is the information for that image:
object.attachments[].image object The preview image for photos or videos.
object.attachments[].image.url string URL of the link.
Here's a link to all of the activities available if the above information isn't enough:
https://developers.google.com/+/api/latest/activities#object.originalContent
If someone can help me figure out how to define the variable for the image, that'd be awesome.
I figured it out. If anyone needs it, here's the code.
$image='';
if(isset($activity['object']['attachments'])){
foreach($activity['object']['attachments'] as $att){
if(isset($att['image']['url'])) {
$src = $att['image']['url'];
To call it out:
<img src='$src'>
<?php
$image='';
if(isset($activity['object']['attachments']))
{
foreach($activity['object']['attachments'] as $att)
{
if(isset($att['image']['url']))
{
$src = $att['image']['url'] ;
}
}
}
?>
<img src='<?php echo $src ?>'>
Works a Treat - https://developers.google.com/+/api/latest/activities#object.originalContent
<?php foreach($activities['items'] as $activity): ?>
<div class="activity" >
<div class="title" ><a href="<?php echo($activity['object']['url']) ; ?>" ><?php echo($activity['object']['content']); ?></a></div>
<p>Published at <?php echo($activity['published']); ?></p>
<p>
<?php echo($activity['object']['replies']['totalItems']); ?> Replys .
<?php echo($activity['object']['plusoners']['totalItems']); ?> Plusoners .
<?php echo($activity['object']['resharers']['totalItems']); ?> Reshares
</p>
</div>
<?php endforeach ?>
Another Way to add to the Feed is with replies, plusoners and reshares

How to opening images on the same page?

I have an album plugin (php) that creates thumbnails for my images in one page and when i click on images opens each image in a new page.
Is there a way to opening images on the same page of thumbnails?
This is my code of thumbnails:
<div class="thumbs">
<?php foreach (wppa_get_thumbs() as $tt) : global $thumb; $thumb = $tt; ?>
<img src="<?php wppa_thumb_url(); ?>" alt="*" />
<?php endforeach; ?>
</div>
and this is the code of specific photo:
<?php } else if (wppa_page('single')) { // if is showing a specific photo ?>
<a href="<?php wppa_photo_url(); ?>"><img src="<?php wppa_photo_url(); ?>" alt="<?php wppa_photo_name(); ?>" class="big" <?php echo wppa_get_fullsize(); ?> />
</a><br />
<?php } ?>
And this is the function that creates links:
// get link to photo
function wppa_photo_page_url($return = FALSE) {
global $thumb;
$url = get_permalink() . wppa_sep() . 'album=' . $_GET['album'] . '&photo=' . $thumb['id'];
if ($return) {
return $url;
} else {
echo $url;
}
}
I tried to remove the link code but does not work.
The act of opening a link in a new window is usually associated with the "target" attribute of an anchor. For example, this would put links in new windows:
text
But the code you've pasted above does not appear to include target attributes in , so I suspect the behaviour is controlled in your CSS, which you didn't include in your question.
Check your CSS files, and look for "target". The W3C has published documentation that describes how this works.
It's actually very easy to do using plain javascript's Image object. You can have a function that does something like this:
function load_image(image_path)
{
var image = new Image();
image.src = image_path;
return image;
}
You can pull the url to the image from the link that they click on.
Then, append that image to a hidden div you have and make it visible. If you're using jQuery:
var image = load_image("/path/to/your/image.jpg");
$(image).appendTo("#your-image-div");
$("#your-image-div").show();
This is untested, but should work.
You could use a jQuery plugin like Lightbox to pop the content dynamically over the current page.

Get a users latest youtube videos?

I'm looking for a way get the following from a users youtube name or url.
thumbnail
link to video on youtube.com
Title of the video
Need to do it with PHP. Is there some youtube api I can use or is something like simple pie my best bet?
Look at the code
<?php
error_reporting(E_ALL);
$feedURL = 'http://gdata.youtube.com/feeds/api/users/USER-ID/uploads?max-results=50';
$sxml = simplexml_load_file($feedURL);
$i=0;
foreach ($sxml->entry as $entry) {
$media = $entry->children('media', true);
$watch = (string)$media->group->player->attributes()->url;
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
?>
<div class="videoitem">
<div class="videothumb"><img src="<?php echo $thumbnail;?>" alt="<?php echo $media->group->title; ?>" /></div>
<div class="videotitle">
<h3><?php echo $media->group->title; ?></h3>
<p><?php echo $media->group->description; ?></p>
</div>
</div>
<?php $i++; if($i==3) { echo '<div class="clear small_v_margin"></div>'; $i=0; } } ?>
Code is copied from the post SimpleXML loop works but breaks half way through
It will get a users all youtube videos. Now it is very easy to develop your own.
Know more about YouTube API from https://code.google.com/apis/youtube/2.0/reference.html
YouTube has got an API available. You can see the reference here: https://code.google.com/apis/youtube/2.0/reference.html
http://code.google.com/apis/gdata/articles/php_client_lib.html
and
http://code.google.com/apis/youtube/2.0/developers_guide_php.html

Categories