HowTo: Old photo Gallery App will live for ever 😎

With the new Photo App there is no public shared Photo Gallery View available.
(Since Nextcloud Version 18)

Problem:
“…the motivation of people to work on the Photos app is pretty much disappeared, so the people who complained have achieved the exact opposite of what they wanted: this feature is still not done because unhappy developer = unproductive developer.”
Reference:

So - let the old Photo Gallery App of Nextcloud live for ever :slightly_smiling_face:

HowTo:

1.) Get old gallery app and unzip:
https://github.com/nextcloud/gallery/archive/master.zip

2.) Copy directory “gallery-master” into Your nextcloud directory:
/apps

3.) Rename director:
/apps/gallery-master
to:
/apps/gallery

4.) Replace the file purify.js:
/apps/gallery/js/vendor/dompurify/src/purify.js
has to be replaced by the file:
https://raw.githubusercontent.com/cure53/DOMPurify/1.0.11/dist/purify.js

5.) Edit max-version:
in file:
/apps/gallery/appinfo/info.xml:

...
<dependencies>
        <nextcloud min-version="18" max-version="999" />
</dependencies>
...

6.) In Nextcloud 20+ the function escapeHTML was removed

Copy function escapeHTML from beginning of file:
https://github.com/nextcloud/circles/blob/workarounds-nc20/js/circles.app.elements.js

and paste in front of file:
/apps/gallery/js/app.js

7.) Login as admin into nexcloud and activate app "Gallery"

=> Have fun with sharing Your pictures! :sunglasses:

2 Likes

On Nextcloud 24, one additional change is necessary to get the Gallery to work. Open apps/gallery/templates/slideshow.php and change line 23 from

    <div class="progress icon-pause icon-shadow icon-white icon-32"/>

to

    <div class="progress icon-pause icon-shadow icon-white icon-32"></div>

Background

Does somebody have it running with NC 25? I tried but for some reason loading the Gallery app fails:

Could not boot gallery: Class "OCP\App" not found

So far I could not make heads or tails of that message. It seems like it tries to load the main application class of the Gallery but fails for some reason doing so. As far as I could see, that class uses OCP\ApplicationFramework\App as super type, and nowhere is OCP\App mentioned.

The full error is:

{
	"reqId": "",
	"level": 3,
	"time": "2022-11-20T21:52:32+00:00",
	"remoteAddr": "",
	"user": "--",
	"app": "no app in context",
	"method": "",
	"url": "--",
	"message": "App gallery threw an error during app.php load and will be disabled: Class \"OCP\\App\" not found",
	"userAgent": "--",
	"version": "25.0.1.1",
	"exception": {
		"Exception": "Error",
		"Message": "Class \"OCP\\App\" not found",
		"Code": 0,
		"Trace": [
			{
				"file": "/path/to/nextcloud/apps/gallery/appinfo/app.php",
				"line": 19,
				"function": "__construct",
				"class": "OCA\\Gallery\\AppInfo\\Application",
				"type": "->"
			},
			{
				"file": "/path/to/nextcloud/lib/private/legacy/OC_App.php",
				"line": 306,
				"args": [
					"/path/to/nextcloud/apps/gallery/appinfo/app.php"
				],
				"function": "require_once"
			},
			{
				"file": "/path/to/nextcloud/lib/private/legacy/OC_App.php",
				"line": 187,
				"function": "requireAppFile",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/path/to/nextcloud/lib/private/legacy/OC_App.php",
				"line": 141,
				"function": "loadApp",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/path/to/nextcloud/lib/private/Console/Application.php",
				"line": 120,
				"function": "loadApps",
				"class": "OC_App",
				"type": "::"
			},
			{
				"file": "/path/to/nextcloud/console.php",
				"line": 99,
				"function": "loadCommands",
				"class": "OC\\Console\\Application",
				"type": "->"
			},
			{
				"file": "/path/to/nextcloud/occ",
				"line": 11,
				"args": [
					"/path/to/nextcloud/console.php"
				],
				"function": "require_once"
			}
		],
		"File": "/path/to/nextcloud/apps/gallery/lib/AppInfo/Application.php",
		"Line": 274,
		"message": "App gallery threw an error during app.php load and will be disabled: Class \"OCP\\App\" not found",
		"CustomMessage": "App gallery threw an error during app.php load and will be disabled: Class \"OCP\\App\" not found"
	}
}

Found it, the stacktrace was quite misleading. In apps/gallery/lib/AppInfo/Application.php on line #271 you’ll find the following block of code:

/**
 * OCA External
 */
if (\OCP\App::isEnabled('ocutility')) {
        // @codeCoverageIgnoreStart
        $container->registerService(
                'UtilityContainer', function () {
                $app = new OcUtility();

                return $app->getContainer();
        }
        );
        $container->registerService(
                'Helper', function (IContainer $c) {
                return $c->query('UtilityContainer')
                                 ->query('OCA\OcUtility\Service\Helper');
        }
        );
} else {
        // @codeCoverageIgnoreEnd
        $container->registerService(
                'Logger', function (IContainer $c) {
                return $c->query('OCP\ILogger');
        }
        );
}

The if condition is the problem here, as that class (\OCP\App) seems to not exist anymore. Simply changing the condition to false makes the Gallery run on NC 25.

/**
 * OCA External
 */
if (false) {
        // @codeCoverageIgnoreStart
        $container->registerService(

I’ve tested and the app itself and the shares-view do work again without any problems that I could notice.

1 Like

Thanks for helping to keep the Gallery app going. It appears to work well, but only the first 60ish photos show from any one album. It was a little hard to notice this since most of my albums are smaller than that. I don’t know how to debug this myself, but I wanted to post about it in case anybody else can.

True, didn’t notice.

The request which is made by Gallery contains all images, the frontend just doesn’t load all images. I think that some “scroll listener” or something isn’t working correctly anymore. I’ll see if I can find it.

Found it! As I guessed, the scroll listeners responsible for loading the next images are not working anymore with the new versions.

apps/gallery/js/app.js at line 190:

$(document).scroll(function () {

Change to:

$("#app-content").scroll(function () {

apps/gallery/js/galleryview.js at line 173:

var scroll = $(document).scrollTop() + $(document).scrollTop();
// 2 windows worth of rows is the limit from which we need to start loading new rows.
// As we scroll down, it grows
var targetHeight = ($(document).height() * 2) + scroll;

Change to:

var scroll = $("#app-content").scrollTop() + $("#app-content").scrollTop();
// 2 windows worth of rows is the limit from which we need to start loading new rows.
// As we scroll down, it grows
var targetHeight = ($("#app-content").height() * 2) + scroll;

And it’s working again. Later I might be throwing together a GitHub repository or something with these hacks.

HACKED Gallery is now available to gather these hacks together in a single, convenient place.

If something is broken, please open an issue for it on GitHub (I barely visit this site here).

2 Likes

Very nice - I just upgraded to NC25 and gave the photos app another chance - but still don’t like it (it’s slow, no sort options,…)
So I installed the hacked gallery, disabled the photos app and re-enabled the gallery…
…and at first look everything seems to work!

Well done!!!