fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
492 stars 302 forks source link

Linked media photos fail to display #1228

Closed hamx0r closed 7 years ago

hamx0r commented 7 years ago

I imported a GEDCOM from MyHeritage which includes media links to many photos. All of the links are full URLs like this: https://www.myheritageimages.com/G/storage/site145832171/files/50/04/96/500496_2277468l4b0f5862y7x765.jpg

However, none of these linked photos display for a user's profile thumbnail, nor for thumbnails in the Media tab of their individual.php page.

image

Any clues as to why? I can take a stab at fixing if an English description of why this happens is provided.

fisharebest commented 7 years ago

webtrees currently has no ability to create thumbnails from URLs. It can only create them from local files.

For historic reasons, webtrees stores the thumbnail alongside the file. The thumbnail for photo.jpg will be thumbs\photo.jpg. This isn't possible for URLs.

For webtrees 1.8.0, we are dropping support for old versions of PHP, which means we can now use some modern HTTP and image-handling libraries, so this feature may be added in the future.

hamx0r commented 7 years ago

If I contribute a solution, would you prefer it use any particular library?

A solution I considered was to add in a hook so that when Media is retrieved:

  1. Look to see if the path starts with "http[s]".
  2. Look to see if local copy exists. If so, use it.
  3. If not, fetch the actual image and store it in a path equal to the rest of the URL, within the data tree (ie data/media/www.myheritageimages.com/G/storage....) and create a thumbnail. This is the cache which will be used next time.

In this way, data is only fetched from an external source only when the picture is attempted to be viewed.

Another solution would be to add a button to "Fetch remote media", which would follow all Media links in the DB to cache locally, overwriting the cache so long as media still existed at the remote location (if if a 40x or 50x error, then leave cache alone). The problem i see here is it's more involved (adding a button) and at risk of getting rate limited by destination (ie myheritageimages.com).

Thoughts?

fisharebest commented 7 years ago

Thoughts?

If we are going to fetch the remote file to create a thumbnail, then we may as well update the OBJE record to point to the new/local image file.

fisharebest commented 7 years ago

Linked images are now used as their own thumbnails.

brianegge commented 5 years ago

I had the same symptoms, different problem. My THUMBNAIL_WIDTH had an empty value in it after PGV import.