Jump to content

jacmaes

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by jacmaes

  1. @adrian That's what I first thought too, but no, it's not generated in the corresponding "files" folder. Digging a bit further, it looks like it does not work with @horst's CroppableImage 3 Module, at least in the way I expected it should. So: $page->image->first->getCrop('landscape')->webp->url; does NOT work. But: $page->image->first->webp->url; does generate a Webp variant correctly.
  2. I have WebP support enabled in GD (PHP 7.3), but $image_field->webp->url still returns a JPEG file. Anything I'm missing? Is there something to add in the config.php file?
  3. @Peter Falkenberg Brown I had the same question. Ryan told me that the single version is in fact part of ProDevTools package. I ended up buying the dev version.
  4. Thanks for sharing. It's nice to see you're using the newer API additions such as $page->if() and setting(). I get excited when I learn about these from the blog posts, but then I forget to use them in my new projects…
  5. Here's @Robin S code adapted to produce the following thumbnail navigation (semi-transparent thumb #98 is the current one): <?php // Number of thumbs to show $limit = 9; // Get the number of visible siblings $num_siblings = $page->parent->numChildren(true); // The default start value is zero $start = 0; // If the number of siblings is greater than the limit then we need to adjust the start value if($num_siblings > $limit) { // Get the halfway point of the limit $half_limit = floor($limit / 2); // Get the index of the current page relative to its siblings $index = $page->index(); // Adjust the start value to keep the current page within the sibling links if($index > $half_limit) $start = $index - $half_limit; if($num_siblings - $start < $limit) $start = $num_siblings - $limit; } $items = $page->siblings("start=$start, limit=$limit"); // Next page and previous page relative to current page $next_page = $page->next(); $prev_page = $page->prev(); // Next and previous SVG icons $left_arrow = "<svg role='img' aria-labelledby='previous-icon' class='icon icon--inline' height='24' width='24'><title id='previous-icon'>Next photo: {$page->prev->title}</title><use xlink:href='#icon--left-arrow'></use></svg>"; $right_arrow = "<svg role='img' aria-labelledby='next-icon' class='icon icon--inline' height='24' width='24'><title id='next-icon'>Previous photo: {$page->next->title}</title><use xlink:href='#icon--right-arrow'></use></svg>"; ?> <?php if($items->count > 1): echo "<div class='thumb_gallery'>"; if ($prev_page->id) echo "<a class='thumbnail' href='$prev_page->url'>$left_arrow</a>"; foreach($items as $item): $number = $item->index() + 1; $current = null; if ($item == $page) $current = " aria-current='page'"; echo "<a$current class='thumbnail' href='$item->url'>"; echo "<img class='responsive-images thumbnail__image' src='{$item->photo->size(150,150)->url}' width='75' height='75' alt=''>"; echo "<span class='thumbnail__label'>$number</span>"; echo "</a>"; endforeach; if($next_page->id) echo "<a class='thumbnail' href='$next_page->url'>$right_arrow</a>"; echo "</div>"; endif; ?> I hope this can help someone else. Thanks again @Robin S !!
  6. Great, thanks @Robin S! Your example looks like what I'm looking for. I'll give it a try early next week and report back with my adapted solution, if I manage to make it work.
  7. @LostKobrakai that helped, thanks. @elabx 's suggestion still retrieves unexpected results: Photo #1: nothing shown, as expected. Photos #2 to #6: work. Photo #7: shows only 4 previous images instead the of the expected 6. Photo #8: shows only 3. Photo #9: shows only 2. Photo #10: shows only 1. Photo #11: works. Photos #12 and above: only shows first 10…
  8. Thanks @elabx for pointing me to prevAll(), which I had not encountered yet. Unfortunately, the order is not respected and the results seem also random (sometimes it retrieves fewer results than expected).
  9. On a photographer's site, I have multiple albums. Each album is made up of a series of pages (1 image per page). So navigating the album is matter of going from one child page to the next. Now let's say I'm viewing image number 15 in a very large album containing more than 100 images. Showing the full list of images in this album as a thumbnail gallery and highlighting the current image/page is easy enough: <?php foreach ($page->siblings as $child): $current = null; if ($child == $page) $current = " aria-current='page'"; echo "<a$current href='{$child->url}'><img src='{$child->photo->size(150,150)->url}' width='75' height='75' alt=''></a>"; endforeach; ?> But if my album contains 100 images, it becomes impractical and slow to show the full list of thumbnails. What I'd like to do instead is detect the current page/image position, and show the previous 10 and next 10 images. I've managed to show the next 10 with "slice": <?php $current_position = $page->index(); $next_10 = $page->siblings->slice($current_position, 10); foreach ($next_10 as $child): $current = null; if ($child == $page) $current = " aria-current='page'"; echo "<a$current href='{$child->url}'><img src='{$child->photo->size(150,150)->url}' width='75' height='75' alt=''></a>"; endforeach; ?> How would I go about showing the previous 10 also?
  10. I've tried and double-checked, but no, for some reason, "has_parent" does not seem to work in this case, even if I manually replace $country with a valid parent id. "Parent" does work as expected, but it's of no use here. A bug, or a limitation with "has_parent" maybe?
  11. That's why I tried first, but has_parent does not seem to work as a sub-selector.
  12. Thanks a lot @bernhard. You put me on the right track. I just changed "parent=yourcity" to "has_parent=$country". For posterity, here are the two selectors in my case: $cities = $pages->findIDs("template=city, has_parent=$country"); $photos = $pages->find([ 'template' => 'portfolio_image', 'city' => $cities, ]);
  13. I'm working on a photographer's site. My tree is organized as such: Home --Photography ----Abstractions ------Photo 1 (photo on its own page; template: portfolio_image) ------Photo 2 ----Animals ----Signs ----etc. --Places: ----United States (template: country) ------New Jersey (template: state) --------Newark (template:city) --------Ringwood --------etc. ------New York In each photo's page (e.g. "Photo 1"), I have a page reference field name "city" where I can select the city (e.g. "Newark"). Now in "Places", I'm trying to retrieve all the photos in each country, for example all pics taken in the United States. I need to find the grandparent of "city", i.e. the country where that city belongs to, but "city.has_parent=$country" or "city.parent.parent=$country" don't work: <?php $foreach ($page->children as $country): $photos_by_country = $pages->find("template=portfolio_image, city.has_parent=$country"); foreach ($photos_by_country as $photos): echo $photos->title; endforeach; endforeach; ?> What's the selector for "the grandparent of the city field" is…? Thanks for your help.
  14. From a quick look, I see a typo here: <? foreach($page->we as $member); ?> It should be: <? foreach($page->we as $member): ?> Notice ":" instead of ";"
  15. I did a couple of years ago. It worked fine with three caveats: by default it caches all the pages and files it rewrites, so you have to be mindful of not running out of disk space. I'm not really comfortable letting an automated tool rewrite so much markup. I like to control the output. you can spend a lot of time tweaking and testing all the settings if you're not opting for the default ones. One particular problem I ran into is to exclude image rewrites from the admin. I believe it's possible to exclude directories, but I could not get it to work and it caused all sorts of unforeseen issues, such as images in Ckeditor fields. In the end, I removed it because it was not worth the hassle. I had already implemented on my own all the major optimizations it proposed to do automatically. Like you, I was mostly interested in the WebP conversion anyway. In case you're not aware, @horst is working on implementing WebP in PW.
  16. FYI: Today, January 29, Firefox 65 is out with WebP support. The only major browser left with no WebP support is Safari.
  17. My thoughts exactly. A video + a code console to play with the API, as mentioned before, would be much more effective.
  18. @horst Niiiice! I've just tried on a live server with PHP 7.2 installed. Your code works great. The Webp image is successfully generated from the original JPEG. Here's how I've echoed it: $main_image = $page->image->first->getCrop('grande'); // (using Horst's Croppable Image module in this example) $image = imagecreatefromjpeg($main_image->filename); imagewebp($image, str_replace('.jpg', '.webp', $main_image->filename)); imagedestroy($image); $webp_image = str_replace('.jpg', '.webp', $main_image->url); echo "<img class='responsive-image' src='$webp_image' alt=''>"; Note: for those using the Plesk control panel, webp support for GD seems to be disabled by default.
  19. Yes, imagemagick supports it: https://imagemagick.org/script/webp.php Thanks @horst!!
  20. I think the Cloudinary image conversion service (they have a generous free tier) could take care of the conversion. They support TIFF. You can use their Fetch method to remotely transform your TIFFs.
  21. @Mikel Pretty sure you can’t subscribe to a list you previously unsubscribed from. It’s a Mailchimp “feature”.
  22. @mel47 Try removing “async defer”.
  23. As @bernhard said, the UI is really nice. It's clever, smooth and minimal, and only shows a wealth of options when you actually need them.
  24. @flydev the clear log button will be helpful, thanks. I have one request: when upgrading to the latest version, I have to manually move the SDK files from the old folder (starting with a dot: ".Duplicator") to the new, updated one. Is there a way to automate this task? It's easy to do manually but I have to remember to do it each time I upgrade.
  25. Goddady's PHP version: 5.4. Good news: Google Drive works flawlessly on my VPS. This is great, thanks @flydev !
×
×
  • Create New...