Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by nbcommunication

  1. "I didn't know you can do this" is definitely a good theme for a blog post @ryan!
  2. Hi @paulbrause, By when rendering do you mean $pageimage->render()? I don't think it is available to this implementation. If you are using the srcset method directly you can do $pageimage->SRCSET or $pageimage->HTTPSRCSET. Cheers, Chris
  3. Hi, StackPath are removing their CDN product from the 22nd of November 2023 so I've removed this module from the directory. If anyone was using it you'll need to stop pretty soon! Cheers, Chris
  4. Thanks @Stefanowitsch, That confirms that the issue is occurring when it tries to JSON encode the data. I'm happy for you to send the print_r() data via direct message if you want me to take a closer look. I also wonder whether trying to log serialize($data) would work, if so that output would be easier for me to work with. Cheers, Chris
  5. Thanks, can you try changing the log to $this->log(json_encode($data)); instead?
  6. Hi @Stefanowitsch, This is odd - getMedia() shouldn't be returning `false`, perhaps the json_encode() of the data is failing, this would explain the false return. Would you be able to edit the module to add a log before line 439? <php $this->log(print_r($data, 1)); if(count($data)) { // Line 439 //... } This output might help to determine why it is failing. Cheers, Chris
  7. Hi @Stefanowitsch, Is the module itself logging anything? You've got your username in the working example - does adding it to the ajax one change anything? Cheers, Chris
  8. Hi @Stefanowitsch, I'd start removing layers of complexity - does getMedia() return something outwith the ajax context? Is anything being logged by the module in Logs? Does the default user account appear in the module config? Cheers, Chris
  9. Hi @Stefanowitsch, Are you using the javascript from the README? I think the UIkit ajax() function has changed so that could be the issue. You could try: fetch(window.location.href, { headers: { 'X-Requested-With': 'XMLHttpRequest', }, cache: 'no-store', }) .then(response => { if (response.ok) { return response.json(); } UIkit.util.addClass(instagram.$loading, 'uk-hidden'); console.error(response.statusText); // ERROR return []; }) .then(data => { // Hide spinner UIkit.util.addClass(instagram.$loading, 'uk-hidden'); if (!UIkit.util.isArray(data) || !data.length) return; // If no items do not render const items = []; data.forEach(item => { switch (item.type) { case 'VIDEO': items.push(instagram.renderItem(item.poster, item.alt, item.src)); break; case 'CAROUSEL_ALBUM': // If 4 or greater items, display a grid of the first 4 images with the rest hidden // Otherwise display the main image (no break, moves to default) if (item.children.length >= 4) { let out = ''; for (let i = 0; i < item.children.length; i++) { out += `<div${i < 4 ? '' : ' class=uk-hidden'}> ${instagram.renderItem(item.children[i].src, item.alt)} </div>`; } items.push(`<div class="uk-grid-collapse uk-child-width-1-2" data-uk-grid>${out}</div>`); break; } default: // IMAGE items.push(instagram.renderItem(item.src, item.alt)); break; } }); const count = items.length; if (count) { // Wrap all items with a div let out = ''; for (let i = 0; i < count; i++) { out += `<div id=instagram-item-${instagram.total + i}> ${items[i]} </div>`; } // Append items to the container UIkit.util.append(instagram.$el, out); // Attach scrollspy listener on last item of second last row if (count > 5) { UIkit.util.on(`#instagram-item-${instagram.total + count - 6}`, 'inview', () => instagram.get()); } // Update total instagram.total = instagram.total + count; } }); The next thing to do would be to try and get the full output that the script is returning. I'm not familiar enough with fetch() to know for certain but you could try console.log(response.text()); after the error log to see if that gives you it. My experience with the errors you've mentioned is that the first is caused by HTML being output/echoed before the JSON, and the second is usually caused by a deprecation notice being output. If you've got $config->debug enabled, try switching that off - if that works then check your logs to see what is triggering the notice and see if it can be resolved. Hope that helps, Chris
  10. Hi @bdbdbd, It isn't the way I'd do it but if it is working for you then that's great. I'd probably add something that checks whether a resized version exists already prior to resizing. If it exists, perhaps update the file modified time if that's possible, and then have a bit of a script to remove images that are older that a set time period, could be anywhere from 1 day to 6 months depending on how often the feed is updated. Cheers, Chris
  11. Hi @bdbdbd, The size() method needs to be called on a Pageimage object (an image saves to a Pageimages field) - it can't be called on an image directly. Saving the images to an image field would end up being quite tricky as you'd need to handle checking if the image already exists, and removing old images too. Honestly, I'd recommend just using the images from instagram, add width="300" height="n" to the <img> tag. I say height=n as this will need to be the height that the image would be if it were 300px wide - they aren't all square images. <?php $instagram = $modules->get('InstagramBasicDisplayApi'); // Get 10 images $images = $instagram->getImages(10); $counter = ''; foreach ($images as $image) { $counter = $counter + 1; $width = 300; $height = round(($image->height / $image->width) * $width); echo "<img src=$image->src alt='$image->alt' width=$width height=$height>"; } ?> If you need a 300px x 300px image grid, I'd recommend using a <div> with these dimensions and adding the image as a background-image (background-size: cover). Cheers, Chris
  12. Hi, Now that the page-edit-redirects permission is in the latest master, I've redeveloped this module to list redirects in the system. I've also added a list of redirects present in the htaccess file (that match one of the httpHosts), and a field for filtering the tables. Cheers, Chris
  13. Hi @snck, I'm just doing some testing on the module at the moment and was using this code as an example. Just wanted to let you know that 'allSets' should be set in srcset options alongside 'upscaling'. In this case, you wouldn't need to set upscaling as 'allSets' enables upscaling anyway. Cheers, Chris
  14. Hi @Sanyaissues, It might be that this Textformatter isn't the best fit for your use case, but to hopefully solve your issue: json_decode() can return a stdClass object or an associative array. This module returns a stdClass object. I don't think you can use array_merge() on this (might be wrong, never tried it). To retrieve the field, modify it and save it, this should work: <?php $otherArray = []; $page->of(false); $array = json_decode($page->jsonfield, 1); // associative array $page->jsonfield = json_encode(array_merge($array, $otherArray)); $page>save(); // Or $array = json_decode($page->getUnformatted('jsonfield'), 1); // associative array $page->setAndSave('jsonfield', json_encode(array_merge($array, $otherArray))); Cheers, Chris
  15. Thanks @gornycreative, I don't use TracyDebugger (*hangs head in shame*) but I do wonder whether that is why $this->wire()->page isn't available in the init(). The test I ran was on a new install of the dev branch so it does suggest something additional altering things. Regardless, for the purposes of this module the fix I put in place to use $this->wire()->process should work. I would normally have put this logic in ready() but didn't and can't remember why, so I'd prefer to keep it where it is for now at least. Cheers, Chris
  16. Hi @snck, Indeed, now I've tested both your and my code on an image of the width you'd specified, I can see I put the fix in the wrong place. The latest version 1.0.7 should hopefully resolve this for you. @gornycreative, How odd - I got this way of checking if it is the admin years ago from someone else's module / a mixture of forum post responses. I've never had a situation where it triggered these warnings. If I log $this->wire()->page in init() I get the Page object. However, I do agree that relying on this in init() isn't the correct implementation. In 1.0.7 I've changed this instead to (string) $this->wire()->process === 'ProcessModule' which works for me and should also hopefully resolve the warnings. Cheers, Chris
  17. Hi @flydev, Unfortunately we're not there yet with the scaling setup. However this is an interesting thread, this could be potentially related to https://processwire.com/talk/topic/26070-error-exception-unable-to-obtain-lock-for-session/ which we've never been able to figure out. Cheers, Chris
  18. Stores a GeoJSON FeatureCollection and its bounds drawn on a MapLibre map. Here's the README.
  19. The simplest, quickest, and maybe most useful module I've ever built 🙂 TextformatterJsonDecode: Passes the given text through json_decode(), returning the value (if valid) as a stdClass object. Didn't even bother with a README - does what it says on the tin. Ha need one for the modules repo... This is particularly useful if you are storing JSON from an API in a Page field and want to access it in a similar way to normal Page objects e.g. <?php /* The data { "fieldName": "value" } */ echo $page->api_data->fieldName; // value I'll be using this extensively over the next few weeks, looking forward to it 🙂
  20. Hi @snck, Thanks - I think I found the place where this is failing to generate the 1600x800 variation where it should. I've pushed the potential fix. Can you try it out? I would note that the example implementation I gave above (creating the variation before calling render()) is a better way to implement this as the markup is meant to be a template not a string with actual values, however if the fix I've pushed works, it should work for either implementation. Cheers, Chris
  21. Hi @snck, The approach here seems odd to me but I'm probably misunderstanding the use case. I'd do: <?php $img->size(800,400)->render( [ 'picture' => true, 'srcset' => [ 'rules' => ['800x400', '1600x800'], 'options' => [ 'upscaling' => true, ], ], 'allSets' => true, 'sizes' => '(max-width: 900px) 100vw, ((min-width: 901px) and (max-width: 1200px)) 67vw, ((min-width: 1201px) and (min-width: 1201px)) 50vw', 'class' => 'hero-img', 'alt' => "...", 'markup' => "<img src={src} alt='{alt}' class='{class}' width={width} height={height}>", ] ); I'd then switch off upscaling to see what that would do. What would you expect the markup to be in this case? Cheers, Chris
  22. Hi @Krlos, Yes, Pageimage::render() is for rendering image markup from a PageImage: https://processwire.com/api/ref/pageimage/render/ In your example above, the correct call would be: <section class="about-section pt-48 pb-48" style="background-image: url(<?= $page->images->url ?>); background-repeat: no-repeat; background-size: cover; background-position: center;"> Assuming that $page->images is a single Pageimage object and not multiple images. In this case it would be: <section class="about-section pt-48 pb-48" style="background-image: url(<?= $page->images->first->url ?>); background-repeat: no-repeat; background-size: cover; background-position: center;"> This of course doesn't use srcset in any way. Going on @Stefanowitsch's example above you would need to implement Lazysizes and Lazysizes beset and then add something like <section class="about-section pt-48 pb-48" style="background-image: url(<?= $page->images->first->url ?>); background-repeat: no-repeat; background-size: cover; background-position: center;" data-bgset="<?= $page->images->first->srcset ?>"> to your markup. I'm not familiar with Lazysizes though so doubt this is a working example. If you look through this thread you can see how I implemented srcset background images using UIkit's Image component. Cheers, Chris
  23. Hi @Krlos, Can you please post a code example? Are you are just calling render() without providing a markup template? Cheers, Chris
  24. Hi, We've been looking at using Postmark for some clients and we were delighted to see an existing module WireMailPostmark - https://processwire.com/modules/wire-mail-postmark/. However the note in the initial forum post about it not being used in production by the authors meant that for us we would need to build something a little bit more in line with what we need and can maintain through usage. WireMailPostmarkApp is an implementation of postmark-php, somewhat in line with a previous WireMail module we built WireMailgun - https://processwire.com/modules/wire-mailgun/ - and its usage will be familiar to those who have used that module. Here's the README: https://github.com/nbcommunication/WireMailPostmarkApp/blob/main/README.md Cheers, Chris
  • Create New...