[resolved] Link rel enclosure to img (4 posts)

  1. frinkky
    Posted 3 years ago #

    The feed I have to work with (from a news agency so cannot be changed) contains images using <link rel="enclosure" type="image/jpg" href="url" title="title" />. At present this obviously is not working.

    Is there a way to convert the <links /> to <img src/>? The rewrite function doesn't handle it - will the pro version be able to handle this or do I need to pre-parse the xml feed?

    Thanks in advance

    p.s. Forgot title on last thread - must have needed more coffee ;)


  2. frinkky
    Posted 3 years ago #

    Ok, rather than messing around with pre-parsing. I've edited the following function at around line 298 of campaign_fetch_functions.php to match links rather than imgs (works according to this regex tester):

    /*** Devuelve todas las imagenes del contenido	*/
    function parseImages($text){
    preg_match_all('/<link rel=\"enclosure\" type=\"image\/jpg\" href=\"(.+?)\"(.+?)\/>/', $text, $out);
    return $out;

    I've also edited (around line 238) with changes in comments:

    if($this->cfg['imgcache'] || $campaign['campaign_imgcache']) {
    $images = $this->parseImages($this->current_item['entry']); // Was 'content'
    $this->current_item['images'] = $images[1];  // Was $images[2] - lista de url de imagenes
    $itemUrl = $this->getReadUrl($item->get_permalink());

    Still, although the new regex is picking up the urls for the images, albeit in an array, no image is being cached/linked whatever. No errors in the logs either.

    Any ideas?

  3. frinkky
    Posted 3 years ago #

    Thought I'd upload a shot of the regex results: https://dl.dropbox.com/u/23205718/regex-output.png

  4. etruel
    Plugin Author

    Posted 3 years ago #

    can you give the feed that you are using?
    you can contact me here: http://www.wpematico.com/wpematico/ and I'll answer you by email

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WPeMatico
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.