Set up Gallery Pro
After viewing the examples in the Gallery Pro introduction, follow these steps to prepare your photos and hosting. You do not need to understand the code or type commands in a terminal; copy the supplied snippets into the specified fields. See Settings and photo information for the settings tables.
Install in Blocs
In Blocs 6.2.1 or later, use the Extension Pac to install both Gallery Pro and Gallery Pro Admin together.
- Download the Gallery Pro 1.1.7 Pac.
- In the Blocs menu bar, choose Window → Extension Manager. Click + at the top right and select
gallery-pro.bexpac. - After installing, search for “Gallery Pro” in Extension Manager and check that these three entries appear.
| Entry | What it represents |
|---|---|
Gallery Pro (1.1.7) : Rino | The Bric you place on the public page |
Gallery Pro Admin (1.1.7) : Rino | The Bric you place on the admin page |
Gallery Pro: x2 Extensions (1.1.7) : Rino | The Pac that contains both Brics |
Extension Manager after installation, filtered by “Gallery Pro.”
Update an existing site
- In Extension Manager, click Check for Updates. If an update is available, click the download button on the individual Gallery Pro or Gallery Pro Admin entry. If an older version shows no update, install the Pac directly.
- Reopen the existing Blocs project. If Bric Updater appears, use the arrow on the row for the Bric instance you want to update. Choose Update All to update every listed instance.
- Select each public and admin Bric and check settings such as Path and Hyphen URLs. In the sidebar, choose Page Attachments → View to check the attached files. Replace any older attachments that remain with the PHP, CSS, and JavaScript files from the updated Bric.
- Save and publish again from Blocs. Check the photo listing and individual photo URLs on the public gallery, and check that you can upload and save in Admin.
The circular arrows next to the search field are the Check for Updates button.
Bric Updater lets you choose which Bric instances to update in the Blocs project.
For the public Bric's files, see Check attachments. Admin uses gallery-pro-admin.php, gallery-pro-admin.css, and gallery-pro-admin.js. Make day-to-day photo changes in Admin. When you update the Bric itself, update the Blocs project and publish it again.
Requirements
In your hosting control panel, open the PHP settings or PHP version selector for the domain, select a version from PHP 8.3 through 8.5, and save. The screen names vary by provider. You do not need to install PHP on your Mac.
Use Gallery Pro Admin to add photos from your browser. Use your hosting provider's File Manager to create the photo folder and check its contents. You can also upload photos there. For provider-specific screens and instructions, see the official hosting guides.
Detailed server requirements
| Item | Requirement or purpose |
|---|---|
| Blocs | A Bric for Blocs 6 for Mac |
| PHP | Supports PHP 8.3 through 8.5; operation on PHP 8.6 RC has also been confirmed |
| mbstring | Processes text in photo metadata |
| EXIF extension | Reads shooting details and identifies image formats |
| GD | Generates thumbnails; support for the image formats you use is also required |
| Write access | PHP must be able to write to _gallery/ and its album folders |
| Apache | Individual photo URLs require mod_rewrite and permission to use rewrite rules in .htaccess |
| JavaScript | Displays and controls the gallery and lightbox in the browser |
The examples below publish the gallery page at /gallery/ and store photos under /_gallery/. Blocs places the required files in includes/ and other folders when exporting or publishing. These examples do not cover installing the entire site in a subdirectory such as /portfolio/. The current initialization code references /includes/gallery-pro.php on the published site.
Whether you can use .htaccess depends on your hosting configuration. Apache requires AllowOverride FileInfo, or the corresponding AllowOverrideList setting, to permit rewrite directives. If you cannot configure this, contact your hosting administrator. See the official Apache documentation.
Setup
1. Plan your photo and file locations
This example starts with photos directly in the _gallery/ folder under the document root. The public gallery page is at /gallery/.
(document root)/
├── .htaccess ← Set in Blocs Hypertext Access
├── includes/ ← Publish uploads automatically
│ ├── gallery-pro.php
│ └── gallery-pro-ogp.php
├── js/ ← Publish uploads automatically
│ └── gallery-pro.js
├── css/ ← Publish uploads automatically
│ └── gallery-pro.css
├── _gallery/ ← Create this folder and give PHP write access
│ ├── Example Photo.jpg ← Upload in Admin or File Manager
│ ├── Another Photo.jpg
│ ├── photos.json ← Admin creates this when it saves photo settings
│ └── thumbs/ ← PHP creates this folder
│ ├── Example Photo.jpg
│ └── .catalog.json ← Thumbnails and catalog are generated
└── gallery/
└── index.php ← Set page to PHP in Blocs; PublishThe highlighted rows indicate items you configure or prepare yourself. Configure .htaccess in Hypertext Access in step 4 and enable Htaccess Production Mode so that Publish uploads it. Blocs also publishes index.php after you set the page to PHP and paste the code in step 3.
The diagram shows only the relevant files on the published site. Placing the Bric automatically registers its required files in Blocs. The Gallery Pro files in includes/, js/, and css/ are then uploaded with the site during normal publishing. You do not need to create these folders or find the files inside the Bric and upload them manually.
PHP generates thumbs/, its thumbnails, and .catalog.json when you open the published gallery. Gallery Pro Admin saves published dates, updated dates, and visibility in photos.json next to the photos. Include the photos and photos.json in backups.
Gallery Pro supports JPEG, PNG, GIF, and WebP. JPEGs that retain their metadata are useful for checking shooting details. A gallery configured to show photos directly in _gallery/ displays only the files at that level.
The filename without its extension is also used as the photo ID. For Example Photo.jpg, the URL ends in Example-Photo when Hyphen URLs is on. That switch is on by default: spaces in the file name become hyphens in the URL, and the page turns those hyphens back into spaces. Turn Hyphen URLs off to keep the file name as the URL, including spaces and hyphens. With the switch on, avoid file names that contain a hyphen, and avoid photos whose names differ only by extension.
Check the photo folder and write permissions
Give PHP write access throughout _gallery/. The root folder needs write access to receive photos and create albums. Each album needs it to replace, rename, move, or delete photos and to save photo settings and thumbnails.
- Open File Manager in your hosting control panel.
- Open the document root for the domain you plan to publish to. Common names include
public_htmlandwww. Use the one your provider specifies. - Use New Folder or Create Folder to create
_gallery. If it already exists, use it. - Select
_galleryand check ownership and access under Properties, Permissions, or Change Permissions. If you already have album folders, check that PHP can read and write in those folders as well.
On a server you manage, you can make the account that runs web PHP, such as www-data, the owner of _gallery/ and its contents or give it write access through group permissions. On shared hosting, use your provider's recommended settings. For example, 755 gives only the folder owner write access. If PHP runs as a different account, it needs a way to write to the folder.
To upload photos in File Manager, open _gallery and select Upload. To use Admin, publish the admin page and add photos from Library. Official hosting guides / Add photos in Admin
Check storage after publishing
- After configuring and publishing from Blocs, add a photo and reload the public gallery to check that it appears. If you use Admin, check that you can upload a photo from Library.
- In File Manager, open
_gallery/and check that the generatedthumbs/directory contains display images and.catalog.json. If you use an album, check its ownthumbs/directory. To see.catalog.json, enable Show Hidden Files or Show Dotfiles. For photos with a long edge of 400 px or less, the gallery may use the original image without creating a thumbnail.
If Admin cannot save a photo or the public gallery cannot save thumbnails, send your hosting provider a message like this and include the actual document root and error message.
I need web PHP to create, update, move, and delete photos and management files in
_gallery/under my document root and in the album folders within it. Saving currently fails. Which user runs PHP on my hosting plan, and how should I set ownership and permissions so it can write throughout that photo directory?
2. Place Gallery Pro in Blocs
Place Gallery Pro in the body of the page where you want the photos to appear. Unlike Math Renderer and Code Highlighter, it does not belong in a dedicated Bloc that simply holds extensions. Give the photo listing the width and spacing it needs.
Leave Source → Path empty to show photos directly in /_gallery/. To show an album, enter its folder relative to _gallery/, for example works. Select Layout and adjust the columns, spacing, and captions as needed.
The required files are automatically added to Attachments when you place the Bric. You normally do not need to register attachments manually. To check them, see Check attachments below.
The Blocs editing canvas displays a configuration banner. View the actual photos in a preview that can access PHP, or on the published site. If your preview refers to photos on the published server, set the Base URL in Project Settings to match that site.
Using multiple Gallery Pro instances on one page
You can place multiple Gallery Pro instances on one page, as in the demo. When you click a photo, the lightbox uses the photo listing and lightbox settings of the gallery you clicked.
However, a photo URL does not identify which Gallery Pro instance should open it. If several instances display the same photo, opening that URL directly or reloading it selects the first instance. Consequently, even if you copy a photo URL from the second or a later gallery, the recipient sees it with the first gallery's settings.
More precisely, the Bric uses the first Gallery Pro instance containing the requested photo ID. Avoid duplicate photo IDs when placing different albums on the same page as well. For a layout comparison, place the Gallery Pro instance whose appearance you want for direct photo URLs first.
3. Set the page to PHP and add code before the doctype
Paste the PHP into the Code section of Page Settings. Follow these steps.
- In Blocs, display the page where you will place Gallery Pro.
- Choose Page → Settings from the menu bar. The keyboard shortcut is ⌥⌘P.
- Open General in Page Settings (the leftmost sliders icon) and select PHP from the File Type list. This example publishes the exported page as
/gallery/index.php.
Figure 1: Select PHP from File Type.
- At the top of the same Page Settings window, click Code (the
</>icon). - Open the list above the code field and select
Before <!DOCTYPE>.
Figure 2: Select Before <!DOCTYPE> to insert the code at the start of the page.
- Use the copy button at the top right of the following code block, then paste it into the Page Settings code field. Copy all three lines, from
<?phpthrough?>. If the field is empty, this is all you need to add. If other code is already present, keep it and add this code alongside it.
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/includes/gallery-pro-ogp.php';
?>- Check the pasted code and confirm that the list shows
Before <!DOCTYPE>. Click Done at the bottom right, then save your Blocs project.
Figure 3: The PHP has been pasted. Select Code at the top, set the insertion point to Before <!DOCTYPE>, and finish by clicking Done.
Apply this setting to each page that uses Gallery Pro. Paste the code only once per page, even if that page contains multiple Gallery Pro instances.
Using Code Editor from the Window menu
Blocs also has a separate Code Editor window. Open it with Window → Code Editor in the menu bar. Select Page - Before <!DOCTYPE> from the insertion point list at the top right to edit the same location for the current page. If you already pasted the code in Page Settings above, do not paste it again.
Figure 4: The list in Window → Code Editor. Select Page - Before <!DOCTYPE> for the current page.
What the added PHP does and where it appears in the export
The exported file uses this order:
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/includes/gallery-pro-ogp.php';
?>
<!DOCTYPE html>This code loads /includes/gallery-pro-ogp.php from the document root. When someone opens a photo URL directly, it adds the photo title, image URL, and related information to the social sharing metadata, and makes images and CSS load from the correct locations. Configure the social card for the gallery as a whole under Social Cards in Blocs Page Settings.
With this setup, the PHP you paste is the same whether the gallery page is at /gallery/, /photos/, or /ja/gallery/. Set the paths in .htaccess to match the actual page location. Reusing one language's page under another language's URL requires additional configuration specific to your site.
4. Add photo URL rules to .htaccess
To make photo URLs open directly, add a short configuration in Blocs Hypertext Access. The following example publishes the gallery page at /gallery/.
- If the site is already live, open the document root in your hosting file manager, enable Show Hidden Files if needed, and look for
.htaccess. If it exists, download a backup and check its contents. - In the Blocs menu bar, choose Window → Code Editor, then select
Hypertext Access - htaccessfrom the insertion point list. It is the last item in the list shown in Figure 4. - Copy the code below and paste it into the editor. Keep any existing code. Include any required settings that currently exist only on the server so that they are not lost when publishing. If you have rules for another application such as WordPress, or rules that apply to the whole site, ask your provider where to insert the new rules. Put the gallery rules before rules that send all requests to another page or provide a 404 fallback.
- In Project Settings (⌘,), open Export, enable
Htaccess Production Mode, and save the project. The next Publish operation will upload the file as.htaccess. - After publishing, open a photo and reload its URL to check that the same photo opens.
When Htaccess Production Mode is disabled, Blocs exports the file as htaccess.txt. The photo URL rules do not take effect under that filename. When you enable the mode and publish, Blocs makes a timestamped backup of the existing .htaccess and replaces it with the new contents. Existing settings are not merged automatically, so retain the required contents in step 3. See the official Blocs settings guide.
RewriteEngine On
# Keep photo URLs in the address bar and serve the gallery PHP page.
RewriteCond %{DOCUMENT_ROOT}/gallery/index.php -f
RewriteRule ^gallery/p/([^/]+)/?$ /gallery/index.php?p=$1 [B,L,QSA]For example, the following public URL is handled internally:
Public URL: https://example.com/gallery/p/Example-Photo
PHP target: /gallery/index.php?p=Example-PhotoThe photo URL remains in the browser's address bar. This is an internal rewrite, not an HTTP redirect to another URL.
What each part of the URL rules means
| Setting | Meaning |
|---|---|
RewriteCond ... -f | Applies only if the target gallery/index.php exists |
^gallery/p/([^/]+)/?$ | Matches one photo slug after /gallery/p/; the trailing slash is optional |
p=$1 | Passes the photo slug to PHP |
B | Escapes the captured text before inserting it into the target |
L | Stops processing further rules in this rewrite round |
QSA | Preserves query parameters from the original URL |
See the official Apache documentation for the flags. Since p selects a photo, do not also use it as a query parameter for another purpose.
If you place the page at /photos/, change all three occurrences of gallery in the rules above to photos. This is independent of the album name in /_gallery/works/ and Source → Path. If the gallery page is at the document root itself, use the following rules instead. You do not need to paste both the folder and root versions.
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/index.php -f
RewriteRule ^p/([^/]+)/?$ /index.php?p=$1 [B,L,QSA]5. Publish from Blocs and check the result
Choose Publish from the export menu at the top right of Blocs and publish to your configured hosting server. This transfers the page and Gallery Pro attachments together. For your first SFTP publication, the official guide recommends selecting Full Site to transfer all required files. See the Blocs publishing guide for the steps, including connection settings.
Once publishing is complete, check the following.
- Open
/gallery/and check the photo listing and layouts. - Click a photo and check the lightbox, photo information, and navigation between photos.
- Check that the address bar changes to a photo URL such as
/gallery/p/Example-Photo. - Open that URL directly in a new tab and reload it to check that the same photo opens.
- Check that you can add photos and that the gallery generates thumbnails. See “Check storage after publishing” above for details.
- Share a photo URL on a social platform and check that its title and image appear.
Checking the social metadata in HTML
Open a photo URL and check that the server's HTML response contains all four required Open Graph properties. The values of og:title, og:image, and og:url correspond to the photo, and og:type is website. Social crawlers may not execute JavaScript, so inspecting only the DOM after the page has loaded in a browser is not sufficient. If needed, ask the person responsible for your website to perform this check.
Check attachments
The required files bundled with the Bric are automatically registered as Attachments when you place it. The official Blocs Custom Bric Structure guide explains that they are registered as Project or Page attachments depending on whether the Bric is placed in a Global Area or the regular page area.
| Bric location | Automatically registered as | Where to check |
|---|---|---|
| Regular page area (page-local) | Page Attachments | Paperclip icon in Page Settings |
| Global Area | Project Attachments | Paperclip icon in Project Settings |
Check from the sidebar
- Select Gallery Pro in the editor.
- Look for the green Page Attachments field in the right sidebar. Gallery Pro registers four required files.
- Click View to open the list of registered files.
Figure 5: Gallery Pro placed in the regular page area. Click View to check the attachments.
The following four files appear as Gallery Pro Bric attachments. If they are already listed, you do not need to add them with the + button.
| File | Purpose |
|---|---|
gallery-pro.js | Displays and controls the photo listing and lightbox |
gallery-pro.css | Styles the gallery and lightbox |
gallery-pro.php | Retrieves the photo listing and metadata from the server |
gallery-pro-ogp.php | Generates social sharing metadata and related information for individual photo URLs |
Figure 6: The attachment list in Page Settings. Gallery Pro's four files are registered automatically. Files from other Brics on the same page also appear here.
To check directly from Page Settings, open Page → Settings and click the paperclip icon (File Attachments) at the top.
Brics placed in a Global Area
Files for Brics in a Global Area are registered as Project Attachments. Open Project Settings (⌘,) and click the paperclip icon at the top to check them.
Figure 7: An example of Project Attachments. This screenshot lists files for Navbar Pro and other Brics used in a Global Area.
Automatic registration and folders on the published site
The Bric also contains an internal folder called includes/, but you do not manually copy that entire folder. Blocs places attached JavaScript in the published js/ folder, CSS in css/, and PHP in includes/. These files are included in normal export and Publish operations. See the official Blocs Project Attachments explanation.
Registering a PHP file as an attachment and loading that PHP at the start of the page are separate actions. Manual file registration or individual uploads are unnecessary, but you still need to paste the code into Page Settings → Code → Before <!DOCTYPE> as described in step 3, and configure the photo URL rules in .htaccess.
Password for Gallery Pro Admin
For installation and browser controls, see the Gallery Pro Admin guide. This section covers Apache authentication and a Docker example.
Gallery Pro Admin is a separate Bric. Place it on its own PHP page, leave that page out of navigation and search, and protect the page on the server. The Bric does not show a login form and does not store a password.
On Apache, protect that page with HTTP Basic authentication. After the browser's login dialog succeeds, Apache sets REMOTE_USER to the user name. The page allows changes only when REMOTE_USER or REDIRECT_REMOTE_USER is not empty. Many hosting panels call this a folder password or Directory Privacy. Those features are usually the same Basic authentication, and the panel writes the configuration for you.
The official php-apache image does not read authentication rules from .htaccess for /var/www (AllowOverride None). Put the rule in the image's Apache configuration. If the admin page is published at /gallery-admin/, the file is:
<Directory /var/www/html/gallery-admin>
AuthType Basic
AuthName "Gallery admin"
AuthUserFile /etc/apache2/gallery-admin.htpasswd
Require valid-user
</Directory>Keep the password file outside the published folder. The image may not include htpasswd, so install apache2-utils or mount a file created on the host. The path and container name below are examples.
docker exec -it gallery-php apt-get update
docker exec -it gallery-php apt-get install -y apache2-utils
docker exec -it gallery-php htpasswd -c /etc/apache2/gallery-admin.htpasswd photoadmin
docker exec -it gallery-php apachectl gracefulIf auth_basic, authn_file, or authz_user is disabled, enable it with a2enmod and reload Apache. On the Debian-based image they are usually enabled already. Without this server configuration, the admin page does not list or change photos.
Troubleshooting
| Symptom | What to check first |
|---|---|
| No photos appear | Check for photos directly in _gallery/ if Path is empty, or in the corresponding album folder if Path is set |
| “Gallery could not be loaded.” appears | Check PHP settings, automatic registration in Attachments, the Blocs Publish result, and the hosting error log |
| “The photo folder can't be saved to.” appears | Check the photo folder's permissions and ownership; send the support message above to your provider |
| Clicking works, but reloading a photo URL returns 404 | Check the .htaccess location and that gallery in the rules matches the published page location |
| The entire page returns a 500 error after setup | Restore the .htaccess backup from before editing and check the page; ask your provider about the insertion location and PHP settings |
| Opening a URL shows a different layout | Check whether several Gallery Pro instances use the same photo; a direct URL opens in the first matching instance |
Back to Gallery Pro / Settings and photo information / Gallery Pro Admin guide









