blynx

MarkupProcesswirePhotoswipe

Recommended Posts

Hej,

A module which helps including Photoswipe and brings some modules for rendering gallery markup. Feedback highly appreciated :)

(Also pull requests are appreciated ūüėȬ†- have a new Job now and don't work a lot with ProcessWire anymore, yet, feel free to contact me here or on GitHub, Im'm still "online"!)

petersburger.gif.b4f2866466f2d40855977717dd78f484.gif

Modules directory: http://modules.processwire.com/modules/markup-processwire-photoswipe

.zip download: https://github.com/blynx/MarkupProcesswirePhotoswipe/archive/master.zip

You can add a photoswipe enabled thumbnail gallery / lightbox to your site like this. Just pass an image field to the renderGallery method:

<?php
$pwpswp = $modules->get('Pwpswp');
echo $pwpswp->renderGallery($page->nicePictures);

Options are provided like so:

<?php
$galleryOptions = [
    'imageResizerOptions' => [
        'size' => '500x500'
        'quality' => 70,
        'upscaling' => false,
        'cropping' => false
    ],
    'loresResizerOptions' => [
        'size' => '500x500'
        'quality' => 20,
        'upscaling' => false,
        'cropping' => false
    ],
    'pswpOptions' => (object) [
        'shareEl' => false,
        'indexIndicatorSep' => ' von ',
        'closeOnScroll' => false
    ]
];

echo $pswp->renderGallery($page->images, $galleryOptions);

More info about all that is in the readme: https://github.com/blynx/MarkupProcesswirePhotoswipe

What do you think? Any ideas, bugs, critique, requests?

cheers
Steffen

  • Like 19

Share this post


Link to post
Share on other sites

This is cool! Thanks a lot. In the near future, I want to port some WP sites with galleries to ProcessWire, so I will definitely give it a try. I put it on my loooooooong todo list :) 

Share this post


Link to post
Share on other sites

Hey Blynx,

Thanks for the nice module :)

Not sure, it's probably just me, but to get this working (local MAMP setup) I had to use the full module class name (MarkupProcesswirePhotoswipe) (not the alias Pwpswp) and the css/javascript etc paths were incorrect , so instead of MarkupPwpswp/path-to-files within the .module file, I had to change these to MarkupProcesswirePhotoswipe/path-to-files 

After this all worked nicely :) 

Thanks again!

  • Like 3

Share this post


Link to post
Share on other sites

Ah! yep, I renamed the module later on - thats a bug I will correct later. Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Update is out: https://github.com/blynx/MarkupProcesswirePhotoswipe

Also removed the Pwpswp class alias, because it was pretty pointless. Processwire does not recognise it as a module and I don't really use static methods in that class.

0.5.1 - 2017/07/06, fixes

removed: Removed pointless shortcut alias class  
fixed: Use of correct module/class name for file paths  
fixed: Configuration instructions for file paths  
other: Updated readme  

  • Like 5

Share this post


Link to post
Share on other sites

Yay, update: https://github.com/blynx/MarkupProcesswirePhotoswipe

Now has some simple 'themes', cooler ones later ...

<?php
$pwpswp = $modules->get('MarkupProcesswirePhotoswipe');
echo $pwpswp->renderGallery($page->nicePictures, ['theme' => 'h-scroller']);

// available themes: plain, flex, h-scroller

0.7 - 2017/07/11, themes

fixed: Size option correctly adopts height value
added: Theme functionality
added: Simple themes 'plain' (previous default), 'flex', 'h-scroller'
other: Updated readme
other: No notice on undefined photoswipe options
other: Refactoring

  • Like 5

Share this post


Link to post
Share on other sites

A great module!  I needed a photo gallery for a few websites and this works fantastic.  Please go ahead and get this module published in the ProcessWire Module Directory.

  • Like 2

Share this post


Link to post
Share on other sites

Hey @blynx,

It is voluntary to make this module only compatible with PHP 7 ?

 

I wanted to give a try to your module for a website I am building right now - using PHP 5.6 - but calling the module with :

$pwpswp = $modules->get('MarkupProcesswirePhotoswipe');
$gallery = $pwpswp->renderGallery($page->gallery, ['theme' => 'masonry']);

give me the following error (due to scalar type arguments) :

errphotoswipe.thumb.png.7cd1f87083994cc25ed28abd0d4207ba.png

 

Anyway, already loving it, thanks for making this module. I am using it with InstagramFeed, IsotopeJS and InfiniteScroll in a custom theme - Masonry - based on the Plain one :

 

MarkupProcesswirePhotoswipe.thumb.gif.dedb2554421ab1df139ef3ef8d5cc1e2.gif

 

  • Like 2

Share this post


Link to post
Share on other sites

Nice, glad you like it!

I will consider this and probably change that - thanks for the feedback!

  • Like 2

Share this post


Link to post
Share on other sites

Ok,

so there is the new version out now which includes a gallery type like the ones in the medium articles.

The whole module has been rewritten and I changed the way the galleries are rendered. Instead of weird template files the galleries are now modules which extend the MarkupPwpswpGallery module. Have a look at the readme for some more info.

Everything should work just fine when updating despite the code changes. I build a gallery module which should ensure compatibility in case anyone was using her/his own template file.

This is the new gallery type ‚ÄěPetersburger H√§ngung‚Äú

petersburger.gif.b4f2866466f2d40855977717dd78f484.gif

 

The inspiration for that type: https://github.com/SiteMarina/guggenheim

The linear partition problem:
http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM
https://github.com/crispymtn/linear-partition/blob/master/linear_partition.coffee#L11 (coffee script)

Yet, I implemented a simplier and I guess faster algorithm: https://stackoverflow.com/a/6670011/3004669
Maybe I will implement the original algorithm, too, at some point. ... 

 

  • Like 8

Share this post


Link to post
Share on other sites

Updated to the new version and it completely broke my site on my local machine.

see attached image.

Screenshot at Nov 17 21-41-33.png

Share this post


Link to post
Share on other sites

It looks like Tracy bd call. Either install Tracy or remove that bd() in line 471.

  • Like 1

Share this post


Link to post
Share on other sites

@JasonS

Noooooo, I was afraid this would happen. It is fixed now! Sorry!
Yep, that was a Tracy bd() call ... as a quick fix you may just remove that line ...

  • Like 1

Share this post


Link to post
Share on other sites

I tried to update my installation with the new updated version and still failed to update safely.

 

Screenshot at Nov 21 16-09-46.png

Share this post


Link to post
Share on other sites

Hm!

This is weird - but it looks like a permissions problem on your side? I guess you can fix this by setting the file/folder permissions.
I couldn't find anything wrong here at my place - is the folder name of the module correct?

How did you install it?

Sorry for the trouble - will have a closer look later the week

Maybe try a fresh installation of the module for now -

Share this post


Link to post
Share on other sites
13 minutes ago, blynx said:

Maybe try a fresh installation of the module for now -

Yes, This worked. Thank you for the great module.

I noticed a small typo just FYI.

 

Screenshot at Nov 21 20-54-44.png

  • Like 1

Share this post


Link to post
Share on other sites

Great module @blynx! Thanks for coding it.

Would you consider making a caption option? I can't seem to find any at the moment.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Mats said:

Great module @blynx! Thanks for coding it.

Would you consider making a caption option? I can't seem to find any at the moment.

ah yep, noticed that the captions were missing the other day. Will look into it!

  • Like 2

Share this post


Link to post
Share on other sites

Hi ! Thanks for the module. I tried to install it in a local MAMP setup. But it does not load everything...

Any idea ?

 

Capture d‚ÄôeŐĀcran 2018-05-09 aŐÄ 16.08.22.png

Share this post


Link to post
Share on other sites

Hi!

Mh can't really tell from that screenshot.
One thing I noticed by myself already is, that it doesn't seem to work when caching is turned on - but I can't find the time to work on it right now. : |

Can you have a look into the markup and see what actually was appended, also which actual paths/urls are used which are failing here?

cheers!

Share this post


Link to post
Share on other sites

I have used your great module on my PHP 5.6 installations.  I am working on a new website and would like to use this module.

I am getting the following error on installation:

photoswipe1.thumb.png.35e2fae81dca5a28e6ec50a3e8ab9e00.png

Any help you can provide with how to get this installed would be greatly appreciated.

By the way, I am getting a similar error when trying to upgrade from your version 7.2 to 9.2.2 (whether using PHP 5.6.x, PHP 7.0.x or PHP 7.2.x)

PHP 5.6.x 

photoswipe-pw1.thumb.png.74414ca9482916481ac3abf1a4155deb.png

PHP 7.0.x

photoswipe-pw2.thumb.png.605f1ac6b7de7122348d69ac15186398.png

PHP 7.2.x

photoswipe-pw3.thumb.png.716eb360dcd4b3425b95373daefd6088.png

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot:

    • By MoritzLost
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution ūüôā
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright ūüėÖ
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator
       

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By BitPoet
      MediaLibrary
      Update: MediaLibrary can now be found in the official module list.
      Out of necessity, I've started to implement a simple media library module.
      The basic mechanism is that it adds a MediaLibrary template with file and image fields. Pages of this type can be added anywhere in the page tree.
      The link and image pickers in CKEditor are extended to allow quick selection of library pages from dropdowns. In the link picker this happens in the MediaLibrary tab, where you can also see a preview of the selected image. In the image picker, simply select a library from the dropdown at the top, everything else is handled by standard functionality.
      I've put the code onto github. This module is compatible with ProcessWire 3.
      Steps to usage:
      Download the module's zip from github (switch to the pw3 branche beforehand if you want to test on PW 3.x) and unpack it into site/modules Click "Modules" -> "Refresh" in the admin Click "Install" for MediaLibrary For testing, create a page with the MediaLibrary template under home (give it an expressive title like 'Global Media') and add some images and files Edit a differnt page with a CKEditor field and add a link and an image to see the MediaLibrary features in action (see the screencap for details) Optionally, go into the module settings for MediaLibrary Note: this module is far from being as elaborate as Kongondo's Media Manager (and doesn't plan to be). If you need a feature-rich solution for integrated media management, give it a look.
      Feel free to change the settings for MediaFiles and MediaImages fields, just keep the type as multiple.
      There are some not-so-pretty hacks for creating and inserting the correct markup, which could probably be changed to use standard input fields, though I'm a bit at a loss right now how to get it to work. I've also still got to take a look at error handling before I can call it fit for production. All feedback and pointers are appreciated (that's also why I post this in the development section).

      Edit 09.03.2016 / version 0.0.4: there's now also a "Media" admin page with a shortcut to quickly add a new library.

      Edit 01.05.2016:
      Version 0.0.8:
      - The module now supports nested media libraries (all descendants of eligible media libraries are also selectable in link/image picker).
      - There's a MediaLibrary::getPageMediaLibraries method you can hook after to modify the array of available libraries.
      - You can switch between (default) select dropdowns or radio boxes in the module configuration of MediaLIbrary to choose libraries.
      Edit 10.10.2018:
      Version 0.1.3:
      - Dropped compatibility for ProcessWire legacy versions by adding namespaces
      - Allow deletion of libraries from the Media overview admin page
      - Added an option to hide media libraries from the page tree (optionally also for superusers)