Jump to content

RSS Enhanced with image tags


melissa_boyle
 Share

Recommended Posts

Hi Guys,

I have recently joined bloglovin and have implemented the RSS enhanced module onto my blog, encolsures for images are working ok but I was wondering if I can implement these to be wrapped in an image tag to allow blog lovin to be able to carry imagery through.

Any help would be greatly appreciated.

Thanks,

Mel

Link to comment
Share on other sites

you should probably post this on the module topic itself (in the future, e.g. don't double post this).

https://processwire.com/talk/topic/6540-markup-rss-enhanced/

you can either roll your own custom RSS feed, or you'll need to append an image tag to the description so that it is within the [[CDATA]]

you'd need to add this around line 149

$description .= $this->renderImage($page);

you'd need to add something like this to the module (untested)

    /**
     * add an image to the description
     * 
     *
     */
    protected function renderImage(Page $page) {

        $name = $this->itemEnclosureField;
        if(!$page->template->hasField($name)) return '';
        $fieldObject = $this->fields->get($name); // field object
        $field = $page->$name;
        $fieldType = $fieldObject->type;
        $maxFiles = $fieldObject->maxFiles;

        if(count($field) === 0) {
            return '';
        } else if ($maxFiles != 1) {
            $field = $field->first();
        }

        if($field instanceof Pageimage) {

            $width = (int) $this->width;
            $height = (int) $this->height;

            if ($width && $height && $this->boundingbox) {
                $ratiox = $width / $field->width;
                $ratioy = $height / $field->height;

                $width = min($ratiox, $ratioy) * $field->width;
                $height = min($ratiox, $ratioy) * $field->height;

                $field = $field->size($width, $height);
            } else if($width || $height) {
                $field = $field->size($width, $height);
            }

            return "<img src='{$field->httpUrl}' />";
            
        } else {
        	return '';
        }

        
    }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By prestoav
      Hi everyone,
      PW version 3.0.123
      I've recently tried to upgrade the Blog module in an installation from 2.4.0 to 2.4.5 and now get the following errors when trying to visit Blog > Posts in admin:
      Fatal Error: Uncaught Error: Call to a member function count() on null in /MYSITE/site/modules/ProcessBlog/ProcessBlog.module:1299 Stack trace: #0 /MYSITE/site/modules/ProcessBlog/ProcessBlog.module(1421): ProcessWire\ProcessBlog->renderItemsSummaries(Object(ProcessWire\PageArray)) #1 /MYSITE/site/modules/ProcessBlog/ProcessBlog.module(1989): ProcessWire\ProcessBlog->renderItemsList(Object(ProcessWire\PageArray)) #2 /MYSITE/wire/core/Wire.php(380): ProcessWire\ProcessBlog->___executePosts() #3 /MYSITE/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___executePosts', Array) #4 /MYSITE/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessBlog), 'executePosts', Array) #5 /MYSITE/wire/core/ProcessController.php(333): ProcessWire\Wire->__call('executePosts', Array) #6 /MYSITE/wire/core/Wire.php(380): ProcessWire (line 1299 of /MYSITE/site/modules/ProcessBlog/ProcessBlog.module) This error message was shown because: you are logged in as a Superuser. Error has been logged. I can see posts in Blog > Dashboard and all seems to work still on the front end.

      Anyone else seen this or know of a fix?
    • By Greg Lumley
      Hi! I'm busy building a blog into my first test/learning/free/clients/project 😁

      I've had a look at all the blog examples and there seem to be different ways of doing it. (the point of Processwire, I know)

      It seems this is generally how it's done:
      Master Blog Page
        - Blog Post Child Page
        - Blog Post Child Page
        - Blog Post Child Page What I'm particularly interested in is the Categories. What would you advise?
      Repeater Field?
      Tags?

      I think I've even seen Categories set up as Children of a master Category page too. The pages were hidden containing no 

      What would you recommend? 

      Thank you! 
      Greg. 

      Bare with me, I'm bashing my way through while I learn. 
    • By MateThemes
      Hello everyone!
      I use ryans blog site profile to build my template around it. I use my mamp pro setup with php 7, mysql 5 and apache server. On my local setup the following code works fine:
      <?php foreach(page()->children as $category): ?> <a class='uk-link-reset' href='<?=$category->url?>'> <div class='uk-card uk-card-default uk-card-hover uk-card-body'> <h3 class='uk-card-title uk-margin-remove'><?=$category->title?></h3> <span class='uk-text-muted'><?=$category->numPosts(true)?></span> </div> </a> <?php endforeach; ?> It is the same code as ryan used it, only my css classes. On my live server with the same setup as mamp pro i got following error:

      Does anyone have the same error in this context?
      Thank you very much for your help!
    • By Violet
      Here I'm introducing FlipFall Magazine, our multi-topic blog. It used to run on Wordpress but we recently switched it to ProcessWire. This was done the usual way we do it when converting our sites: install ProcessWire in a subfolder of the original Wordpress site under a hard-to-guess name, set up the new site there, then move content over manually, inspecting and updating each article as needed. After the ProcessWire site was ready, when we un-installed the Wordpress one and moved the ProcessWire site up one level to the document root, and... done.
      We used the W3CSS framework because it handles the responsive breakpoints so well (no extra work for us 😉), and it tends to default to a clean modern look.
      We wanted full control over the back end of the site and do customized things without having to hire a developer.  As FlipFall has grown, the ability to have in-house back-end control has become even more important.
      Case example: Ad partners - we now can quite easily, if we wish, place different ads on different topics on this blog at a moment's notice - no need to hire a developer. Changes like this can be implemented in-house right away. The fact that we can easily incorporate this sort of thing is really nice when we're talking with potential ad partners.
      Helpful features of ProcessWire during this experience:
      The ability to export and import fields in PW was key here. We had a few other article-style sites I had done in PW recently, so having the same types of templates was very helpful. We were able to export fields and templates from our existing sites and import into FlipFall as a starting base point. No need to re-invent the wheel here! Another helpful ability of PW was when we were dealing with the categories. We built the site without category templates (but with the category page field), then added the templates in later as needed - no disruption. In other words, a template-less page field worked perfectly for the categories until we needed the template, then we just created the template. Not every feature of the site needs to be thought out in absolute full beforehand, some can be added in later as needed. Very extensible and convenient. Internal links within blog posts worked well using the page select option in the link button on the editor. When moving out of staging folder and into document root, the links auto-updated, which was nice. Creating new articles is a breeze, because under PW our fields are now customized for our needs: we created all of the fields we need and none of the ones we don't. Again, this is unlike most blogging CMS's, where they try to guess what you want (and usually get it wrong). Even for people who are solely doing blogs/article sites, I feel that ProcessWire is a much better option than most blog-specific platforms, because of PW's flexibility.  The only thing I miss about Wordpress is the ability to auto-schedule post publication, which for the serious blogger is important. For example, there were some occasions on some of our other blogs where we needed to schedule posts to auto-publish at 3:01am Eastern Time to allow a time-sensitive post to come out as early in time of day as possible on publication date (3:01 am US Eastern time ensures it's that same day 12:01 am on Pacific time). We were delighted to see that ProcessWire is much, much lighter on resources of the hosting environment than the same site on Wordpress - we could see this empirically on our web hosting stats before and after the switch.
×
×
  • Create New...