Jump to content

nbcommunication

Members
  • Posts

    268
  • Joined

  • Last visited

  • Days Won

    6

nbcommunication last won the day on June 29 2023

nbcommunication had the most liked content!

1 Follower

Profile Information

  • Gender
    Not Telling
  • Location
    Lerwick, Shetland

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

nbcommunication's Achievements

Sr. Member

Sr. Member (5/6)

425

Reputation

1

Community Answers

  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
×
×
  • Create New...