Open jan356 opened 8 years ago
I need this too. My picture folder is used by an DLNA Server too. The created pwg_representative folder is showed on my TV now ...
me too, pls, pls, pls!
This is the default behavoir of PWG. I believe the thumbnails should be created in the local pwg_representative
directory.
https://github.com/xbgmsharp/piwigo-videojs/blob/master/include/function_sync2.php#L126
How do you detect to write to a specific directory. is it a virtual album?
I don not fully understand your question. Let's try to answer it.
No, I don't use virtual albums in piwigo.
The original file is on read only storage, If I take a jpg file as example /data-hdd/images/2016/dirname/image1.jpg. When I browse the album containing that image, previews will be saved in /data-hdd/piwigo/_data/i/galleries/2016/dirname/image1-xx.jpg, .../image1-sq.jpg etc.
However, when I use your plugin on file /data-hdd/images/2016/dirname/videoname.mp4, the poster is created in /data-hdd/images/2016/dirname/pwg_representative/videoname.jpg, which fails because it is on read only storage.
My proposal is to create the poster in the temporary storage (writable) directory /data-hdd/piwigo/_data/i/galleries/2016/dirname/pwg_representative/videoname.jpg which is writable by the webserver and where also other previews are stored.
Sometimes, when I switch to a different piwigo than the standard one, new previews are also generated in /data-hdd/piwigo/_data/i/galleries/2016. So it looks like that is "standard functionality".
How it relates to your source I don't know (sorry).
Hope this helps. Thanks again.
In include/function_sync2.php
on line 147, can you replace:
https://github.com/xbgmsharp/piwigo-videojs/blob/master/include/function_sync2.php#L147 and https://github.com/xbgmsharp/piwigo-videojs/blob/master/include/function_sync2.php#L238
$output_dir = dirname($row['path']) . '/pwg_representative/';
by:
$output_dir = PWG_DERIVATIVE_DIR . dirname($row['path']) . '/pwg_representative/';
If it is fine for you i will commit the change.
So i try and even so we can write in the derivative directory (using the modification in the previous post), PWG is looking for the current videos folder as mention in the documentation. https://piwigo.org/doc/doku.php?id=user_documentation:learn:add_picture
and you can see it in the code: https://github.com/Piwigo/Piwigo/blob/master/admin/include/functions_upload.inc.php#L551
as a result not sure it is feasible.
Thanks. I changed include/function_sync2.php
as you wrote and then the preview jpg-image is written in the desired place. However, it does not appear in piwigo, as your next comment suggests.
Probably piwigo also needs some modifications? Which means piwigo should search in two places for the preview:
(1) where it searchs now to prevent other installations depending on this to break, and
(2) in $output_dir = PWG_DERIVATIVE_DIR . dirname($row['path']) . '/pwg_representative/';
Do you think that is feasible?
For what it's worth, a (very) crude hack. It works but you'll have to resync thumbs using video_js plugin each time you've synched the gallery using piwigo.
In .../plugins/piwigo-js/include/function_sync2.php. Replace
$output_dir = dirname($row['path']) . '/pwg_representative/';
with
$output_dir = PWG_DERIVATIVE_DIR . dirname($row['path']) . '/';
In .../include/derivate.inc.php find the function build. Replace
if ($url_style == 2) { ... }
with
if ($url_style == 2)
{
if (strpos($loc, "pwg_representative") != false)
{
$replace = array(
"-xs" => "",
"-2s" => "",
"-th" => "",
"-cu_e250" => "",
"pwg_representative" => ""
);
$rel_url = "_data/i/" . strtr($loc, $replace);
}
else
{
$rel_url = 'i';
if ($conf['php_extension_in_urls']) $rel_url .= '.php';
if ($conf['question_mark_in_urls']) $rel_url .= '?';
$rel_url .= '/'.$loc;
}
}
else
{
$rel_url = $rel_path;
}
Thumbnails were being generated but Piwigo galleries were showing them as missing, they were looking for files with a suffix of: -cu_s9999x200
So change the line 150: https://github.com/xbgmsharp/piwigo-videojs/blob/master/include/function_sync2.php#L150 $out = $output_dir.$file_wo_ext['filename'].'-cu_s9999x200'.'.'.$sync_options['output'];
I've been trying to solve this in a structural way, but did not succeed. The directoryname "pwg_representative" is hardcoded in a number of files. As a first step to solve at least the visibility of the pwg_representative directory I've changed this in ".pwg_representative" throughout the code. This seems to work. A better solution would be to make it a $conf variable. Problem is that after each update and for each plugin you install you have to do this again.
Please make a conf variable for this
Hi, is this still on the radar? I've just updated to Piwigo 13 and I seem to still have the issue that thumbnails won't be generated because my photos folder is readonly for the web server.
Hi - could someone please help with my issue: https://piwigo.org/forum/viewtopic.php?id=32431 . In summary my Piwigo set up cannot seem to get the thumbnails for video albums. It's very frustrating. Any help will be appreciated!
Same here WRT read only access to pictures. I tried generating the files with the same name and putting them in 'pwg_representative' sub directory, then using the standard Piwigo sync to add them. Also tried JPG and PNG extensions.
Same here WRT read only access to pictures. It's related to the zfs mounted fs.
I've found a workaround for readOnly album folder structures from www-data user's perspective. Running this daily cron script here to create the "pwg_representative" subfolders for every album which contains *.mp4 files and allowing write access ONLY to those directories.
In /etc/cron.daily/piwigo-set-acl
#!/bin/bash
#####################
# FUNCTIONS START #
#####################
function create_pwg_representative() {
local dir="$1"
#
for subdir in "${dir}"/*; do
#
# Skip files.
if [ ! -d "${subdir}" ]; then
continue
fi
#
# Subfolder already exists?
if (echo "${subdir}" | grep -q "pwg_representative$" ); then
continue
fi
#
# Check if dir contains at least one .mp4 file.
if ls "${subdir}"/*.mp4 &>/dev/null; then
if [ ! -d "${subdir}/pwg_representative" ]; then
mkdir "${subdir}/pwg_representative"
echo "[INFO] Created: ${subdir}/pwg_representative"
fi
#
# This compensates the change from the above setfacl command.
setfacl -Rm u:www-data:rwX,d:u:www-data:rwX "${subdir}/pwg_representative/"
fi
#
create_pwg_representative "${subdir}"
done
}
#####################
# FUNCTIONS END #
#####################
#
#
create_pwg_representative "/datavol/piwigo-pictures"
Thanks for the script, unfortunately it won't really help for read-only storage (Piwigo won't be able to generate the representatives). It'd be best to move the representatives elsewhere, for example in the _data
folder.
Hello, any luck with this? Generating thumbnails/posters in the picture directory is clearly not desirable. Following comments above, I manage to get the plugin to generate posters in the _data/i directory, but it seems piwigo is not able to see them.
When creating a poster (i.e. a thumbnail) for a video file, this is done in the directory [original location of the video]/pwg_representative
However, on my system the directory with (original) image and video files is not writable by the webserver (which is running as wwwrun:www), so when this plugin creates a video poster, I get the warning "Warning: mkdir(): Permission denied in /srv/www/htdocs/piwigo/plugins/piwigo-videojs/include/function_sync2.php on line 132".
Can an option be made to create the video poster in the piwigo cache directory .../_data/i/galleries/..., which is writable by the webserver? Thanks.
Example: original file: /data-hdd/images/2016/dirname/videoname.mp4 now, the poster is created in /data-hdd/images/2016/dirname/pwg_representative/videoname.jpg however the directory /data-hdd/images/2016/dirname/ is not writable by the webserver, so an error is generated.
my proposal is to create the poster in /data-hdd/piwigo/_data/i/galleries/2016/dirname/pwg_representative/videoname.jpg which is writable by the webserver.