Results 1 to 4 of 4

Thread: Enclosure tag images

  1. #1
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Enclosure tag images

    1) Script Title:Advanced ajax RSS Ticker

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ajax/index.htm

    3) Describe problem: Enclosure tag does not show images

    Hi there!

    Does anyone know how can i include pictures that are in enclosure tags - something like this.

    <enclosure url="url-of-image" type="image/gif"/>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To be valid* in HTML they would have to be converted to img or possibly object tags. This could be done via regular expression possibly in either one of the PHP files or in the rssticker.js file. Probably the latter would be easiest because it's at that point that the content first becomes a bonifide string.

    The img tag is more widely supported. So try that. In rssticker.js replace the initialize function with this one:

    Code:
    rssticker_ajax.prototype.initialize=function(){ 
    if (this.ajaxobj.readyState == 4){ //if request of file completed
    if (this.ajaxobj.status==200){ //if request was successful
    var xmldata=this.ajaxobj.responseXML
    if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
    document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText
    return
    }
    var instanceOfTicker=this
    this.feeditems=xmldata.getElementsByTagName("item")
    //Cycle through RSS XML object and store each peice of an item inside a corresponding array
    for (var i=0; i<this.feeditems.length; i++){
    this.title[i]=this.feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue
    this.link[i]=this.feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue
    this.description[i]=(this.feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue).replace(/enclosure/gi, 'img').replace(/\burl=/gi, 'src=')
    this.pubdate[i]=this.feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue
    }
    document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
    document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
    this.rotatemsg()
    }
    }
    }
    This is just an educated guess as I don't have any feeds that I know have enclosure tags for images in them handy to test on. As long as the paths to the images are absolute, it should (barring typos or failure in logic on my part) work. If you want more help give us the URL to the feed with these enclosures in it.


    *enclosure is valid in RSS, just not in HTML.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    nope, that didn't work.

    The rss i must show with images is http://auto1.bg/public/rss/news_en.xml.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I think you would need an updated version of lastRSS.php (assuming there's one and it can parse the enclosure tag) and then some modifications to the bridge.php and rssticker.js (different than the one I suggested as the enclosure tag is not inside the description tag).

    This is not a project I would want to undertake at this time, sorry.

    Alternatively, there are other ways to grab feeds. The Google Feed API:

    http://code.google.com/apis/feed/

    might be able to be used for this. At least it's likely to be more up to date.

    You could also take a look at some of the results of this search:

    http://www.google.com/search?client=...hannel=suggest

    This also looks promising:

    http://www.parorrey.com/blog/php-dev...ing-simplepie/
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •