Search…

X3 Photo Gallery Support Forums

Search…
 
eriknordlund
Topic Author
Posts: 2
Joined: 11 May 2021, 13:50

Questions

12 May 2021, 20:24

Hi,

First of all, thank you for creating Embed. I'm loving the simplicity and customizability while I work on getting my new website up and running quickly. I seem to be running into a couple issues that I can hopefully resolve before publishing my site.

My most prominent issue seems to be a bug with including an image description in an image's caption. My current Embed div is as follows:
Code
<div class="embed" data-embed-app="/files/index.php" data-embed-path="Folder" data-embed-popup-caption-template="{{description}}" data-embed-popup-map="false" data-embed-popup-caption-hide="false"></div>
Any time I include "{{description}}" in the data-embed-popup-caption-template value, image captions appear to be blank. In addition to this, when I click on an image to make it fill the window, that image will show, and the next image will show when I click on the arrow, but none of the other images show on the screen until closing the 'full window' view and clicking on a different image. Both of these issues go away if I don't include "{{description}}" in the caption template value, and this includes cases where the value includes other options which work on their own, e.g. "{{basename}}<br>{{description}}". The image description does appear when I view the image in my site's Files page, so I don't think it's an issue with having no description.

My other issue might have more to do with Files, but I figured I would include it here to start, and if I should move this question to the Files section, I would be glad to do so.

In the Files index.php file around line 1125, the "basic post access security: XMLHttpRequest + post_hash created from server paths" if statement seems to be failing on my site, due to the "post('post_hash') !== md5(__FILE__ . $_SERVER['HTTP_HOST'])" check failing. I've briefly investigated this so far, and post('post_hash') is returning false, so I don't think the hash is being provided to the Files index.php endpoint. Unfortunately, my JS skills are nonexistent, and I can't find "post_hash" in the embed.min.js file, so I've hit a dead end in debugging this. For now, I can comment out this check, and it works. My only idea is that the site is currently without a domain, and so it would only have the IP address to work with for creating the post_hash.

If I can offer any other help in figuring this out, I'll be happy to do whatever I can.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Questions  Topic is solved

12 May 2021, 21:42

Hi. Glad you found Embed useful and thanks for feedback! Although Files app has been out for a while, Embed is brand new and we don't really have many users (that I am aware of).
eriknordlund wrote:In the Files index.php file around line 1125, the "basic post access security: XMLHttpRequest + post_hash created from server paths" if statement seems to be failing on my site, due to the "post('post_hash') !== md5(__FILE__ . $_SERVER['HTTP_HOST'])" check failing. I've briefly investigated this so far, and post('post_hash') is returning false, so I don't think the hash is being provided to the Files index.php endpoint. Unfortunately, my JS skills are nonexistent, and I can't find "post_hash" in the embed.min.js file, so I've hit a dead end in debugging this. For now, I can comment out this check, and it works. My only idea is that the site is currently without a domain, and so it would only have the IP address to work with for creating the post_hash.
I'll answer this first because it's easy. The "security" feature you are referring to can only work from Files app since it runs directly under PHP. For Embed, it needs to be removed/disabled. You can simply delete the following chunk of code from Files app index.php around line 1127:
Code
// basic post access security: XMLHttpRequest + post_hash created from server paths
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || 
  $_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest' || 
  post('post_hash') !== md5(__FILE__ . $_SERVER['HTTP_HOST'])) json_error('Invalid request hash. Please Refresh browser.');
This is actually already removed from the Files index.php published with Embed:
https://cdn.jsdelivr.net/npm/embed.phot ... /index.php

I will be removing this from next Files release, since it doesn't work with Embed and it doesn't really provide any benefit.
eriknordlund wrote:My most prominent issue seems to be a bug with including an image description in an image's caption. My current Embed div is as follows:
The instructions referring to {{description}} was just a simplification and perhaps bad example, as I didn't think anyone would be using data-embed-popup-caption-template (yet at least). The problem is therefore that {{description}} is creating an error which causes the issues.

Caption templating can be a bit tedious. Descriptions are actually stored in {{image.iptc.description}}, but unless ALL your images contain a description, you need to include @if() syntax from the template engine squirrelly.js.org to validate if properties exist. Something like this:
Code
{{ @if(image.iptc)}}{{image.iptc.description}}{{ /if}}
Depending on your images and requirements, you might also need more @if @else syntax to create the desired output.

Before messing around too much with caption templates, could you not use the default caption which already includes IPTC data? It would be easier to hide and format caption elements from your CSS.
 
eriknordlund
Topic Author
Posts: 2
Joined: 11 May 2021, 13:50

Re: Questions

12 May 2021, 23:02

Your recommendations worked perfectly for what I'm doing! Thank you for such a quick and effective response.

I forgot one more thing, having to do with thumbnail backgrounds for images with transparency. It seems like once the image resolution reaches a threshold, the resized thumbnail from Files has a black background where the transparency was. Is this something that can be changed/adjusted on my end?

Thank you again!
Erik
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Questions

13 May 2021, 01:44

eriknordlund wrote:I forgot one more thing, having to do with thumbnail backgrounds for images with transparency. It seems like once the image resolution reaches a threshold, the resized thumbnail from Files has a black background where the transparency was. Is this something that can be changed/adjusted on my end?
Embed will only serve resized images when original image dimensions are beyond a certain threshold. For example, if your original image is 640 px, it would be pointless to waste resources to create a 480 px resized re-compressed image. Instead, it will simply serve the original, which of course may include transparency if PNG or GIF.

Thus, when you have resized images, which happens in most cases, they will always output as JPG, and JPG does not support transparency. It would be pointless to serve resized images as PNG/GIF, as they don't compress well compared to the original. It is possible to REPLACE the default black color with another color when outputting images with alpha to JPG:
https://stackoverflow.com/questions/424 ... g-resizing

It would require a few lines of code in the Files PHP, and I wouldn't want to add it by default, because it requires more processing. It could perhaps be an option, and it would only attempt to apply on PNG/GIF formats.
 
RonAckerman
Posts: 8
Joined: 23 Jul 2021, 17:50

Re: Questions

26 Jul 2021, 20:43

Hello,

I am trying to embed on a Wordpress page. My path is <domain>/library/index.php however it doesn't seem to be picking up the path. Is there something to the path that I'm missing?

<div class="embed" data-embed-app="/library/index.php" data-embed-path="library"></div>
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Questions

27 Jul 2021, 00:45

RonAckerman wrote:<div class="embed" data-embed-app="/library/index.php" data-embed-path="library"></div>
Possible you can send me a link? I'm virtually blind without any reference. Embed is quite new, little documentation, and there are some pitfalls. Also, are you using the Files "index.php" from the Embed gallery? There are a few lines of code in the original Files app index.php that are not compatible with Embed app, something I am fixing with forthcoming Files app release.

Perhaps you can try to use the "chat" button (bottom right on this page) so I can assist more effectively? Optionally, use email. I should be online throughout the day, depending on your timezone.
 
RonAckerman
Posts: 8
Joined: 23 Jul 2021, 17:50

Re: Questions

27 Jul 2021, 09:13

No! I can't seem to find a download link for the embed index.php. 
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Questions

27 Jul 2021, 11:09

RonAckerman wrote:No! I can't seem to find a download link for the embed index.php. 
Sorry, It was here!
https://cdn.jsdelivr.net/npm/embed.phot ... /index.php
 
RonAckerman
Posts: 8
Joined: 23 Jul 2021, 17:50

Re: Questions

27 Jul 2021, 11:37

Thanks for giving in a go with embed. I'm looking forward to the next update.  As a side note, for my purpose, I would need the ability to download a folder/directory.  Also it seems I'm unable to exclude folders the start with a period like .tmb.

Thanks again
Ron
 
RonAckerman
Posts: 8
Joined: 23 Jul 2021, 17:50

Re: Questions

27 Jul 2021, 12:41

FYI the symlink works as long as the it's not the root directory. Example I put the symlink into the tools directory and it will display. However some other issue have come up. I see directories with no file names. And that is the only view. No side menu, or any menu. So I can see the directory but don't know what directory it is. Open the directory and I see all the files but have no idea what they are?

http://bluegrassjams.org/index.php/library-2
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Questions

28 Jul 2021, 02:34

RonAckerman wrote:As a side note, for my purpose, I would need the ability to download a folder/directory.
It's not possible to simply download a directory (like one downloads a file). The only option is to ZIP the folder, and then download the zip.
RonAckerman wrote:Also it seems I'm unable to exclude folders the start with a period like .tmb.
Did you try the data-embed-exclude="regex" option?

Just before I make a few more suggestions, I would like to emphasize why I recommended that Embed was a bit off scope currently in your case:
  • Embed was created mainly to as a gallery (with emphasis on photos) that can be added to any website, loading files and images located in the public www.
  • In your case, you are using symlinks, that not only point elsewhere, but point to files and folders that are outside the public www, which means these files don't have a path relative to the URL, and need to be "proxied" by Files app. Although Files app is created with this in mind, Embed not so much.
  • You are missing some MIME checking functions in your PHP, which may not be directly related, but causes further complications to the above. This will be resolved in next Files app release.
  • Unlike Files app, which has a sidebar menu to navigate folders, Embed is just an "embed" of a gallery into the website. You can navigate folders, but it doesn't add any menu's into the website (where would it get added)?
Not saying there isn't room for improvement, but just stating where we are at.
RonAckerman wrote:I see directories with no file names. And that is the only view. No side menu, or any menu. So I can see the directory but don't know what directory it is. Open the directory and I see all the files but have no idea what they are?
Because I want Embed to impose a minimal amount of predefined styles on the custom website, and because the primary focus is "photos", this is not included by default. However, you can easily add captions by including a embed-captions-default class:
Code
<div class="embed embed-captions-default" data-embed-app="/tools/embed.php">
Image
Optionally, you can also style your own captions from pure CSS.
RonAckerman wrote:No side menu, or any menu.
Unlike Files app, there is no "menu" in Embed. It simply embeds the gallery, and if you need to navigate, you would need to navigate by clicking the folders, using browser back/next buttons, and the breadcrumbs menu that appears once you navigate to a sub-directory. Unlike Files app, We can't really include a menu in Embed.

Hope it helps!