WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. frinkky
    Member
    Posted 1 year 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 ;)

    http://wordpress.org/extend/plugins/wpematico/

  2. frinkky
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

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

  4. etruel
    Member
    Plugin Author

    Posted 1 year 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

About this Topic

Tags

No tags yet.