Jump to content

Media Manager Archive


kongondo

Recommended Posts

13 minutes ago, kongondo said:

This is a relatively old version of ProcessWire. Any reason why you are not on the latest main/master version (3.0.200) at least?

No special reason. Maybe it's the best, I install a fresh new system and media manager again. Now its only a small test/experimental system. It is enough to backup the /site/modules/ProcessMediaManagermediamanager folder for later re-install Media Manager?

Link to comment
Share on other sites

24 minutes ago, kono said:

Maybe it's the best, I install a fresh new system and media manager again.

Yes. It is a good idea, especially if you want to take advantage of newer features. I am not saying it is the reason for the errors you are experiencing. ProcessWire tends to be very stable across versions. It could be a case of Media Manager using one of the newer ProcessWire features. 

24 minutes ago, kono said:

It is enough to backup the /site/modules/ProcessMediaManagermediamanager folder for later re-install Media Manager?

Upgrading ProcessWire is mainly a matter of swapping out /wire/ with the current latest one. However, some files such as index.php, .htaccess might also need overwriting with their latest counterparts. However, just in case something went wrong, it is a good idea to create a database backup of your site in case you needed to roll back. In the case of Media Manager itself, if you have implemented lots of changes and uploads, you might want to back those up. However, if you don't mind losing these (since you are still experimenting), I'd start from scratch. As for the Media Manager files themselves, the ProcessWire upgrade will not affect them. However, to ensure a fresh start, it is better to fully uninstall Media Manager, then upgrade ProcessWire. In summary:

  1. Create a whole site backup (e.g. using ProcessDatabaseBackups or some other database tool).
  2. Completely uninstall Media Manager.
  3. Upgrade ProcessWire. Please see the docs here.
  4. If the upgrade goes OK, do a module refresh on the site.
  5. Install & enable Tracy Debugger (if you don't have it already).
  6. Re-install Media Manager.
  7. Test Media Manager features.

Please let me know how it goes.

  • Like 1
Link to comment
Share on other sites

I have updated now to the latest pw version - it seems the Media Manager problem has vanished into thin air ?

I am now trying everything exactly and will give you feedback again later...

Thank you very much for your very quick an friendly help!

Kono

Link to comment
Share on other sites

Hi @kongondo,

thank you very much! It's done and works so fare. I have deleted the account again.

Some more question for understanding, sorry:
Do I necessarily need the html tags for the frontend output (e.g. video):

echo "<video width=320 height=240 controls>";
echo "<source src='" . $m->media->url . "'type=video/mp4>";
echo "</video>"


Or should that be enough to render a player in the frontend?

echo $m->media_manager_video->url

What is the shortest way to render the player in the frontend?

Thanks for the effort!

Kono

Link to comment
Share on other sites

Hi @kono,

16 hours ago, kono said:

What is the shortest way to render the player in the frontend?

Echoing the field ?. Media Manager field has as toString() method.

<?php

namespace ProcessWire;

// toString()
echo $page->name_of_your_media_manager_field;

The above will render each item in the media manager field according to its type, i.e. audio (audio player), video (video player), image (thumb 400px wide, height auto) or document (file name with URL - viewable in browser or downloadable depending on document extension) Please see the docs here.

Hope this helps.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
33 minutes ago, bubu2110 said:

How can I use the ToString() function?

Do you even need it? Normally you can access the field directly: $page->name-of-the-field
Or do you have an example where it is needed?

Link to comment
Share on other sites

4 hours ago, zoeck said:

Do you even need it? Normally you can access the field directly: $page->name-of-the-field
Or do you have an example where it is needed?

Grüß Gott ?

If I use it like you mentioned it, I will get my image with HTML-Tag. F.E.: $page->name-of-the-field returns <img src="path/img.jpg" />
But I need the path to the image only to use it as a background-image.

Thank you

Link to comment
Share on other sites

Hi @bubu2110,

Welcome to the forums.

20 minutes ago, bubu2110 said:

But I need the path to the image only to use it as a background-image.

Please see the following documentation for Media Manager:

  1. Media Manager Objects - link.
  2. Accessing Media Manager Objects Properties - link.

Other topics listed under Frontend Output of Media Manager Fields would also be of interest.

Please let me know if you require further assistance.

Link to comment
Share on other sites

Hi @kongondo and many thanks for this great module.

I just installed it on PW 3.0.200 / PHP 7.4 and encountered an issue with uploads of SVG, be it from the MM Upload section or the mm field that I created for type images. 
FileValidatorSvgSanitizer is also installed.

There is a PHP Warning related to JqueryFileuploads module

jqfu-error.png.ad5c06e93d6ea34bcebab5da1cd3ab3d.png

Problem is the getImagesize($imageFile) call which returns false for SVG images. I scanned the JqueryFileuploads thread for posts related to SVG and found none. Wondering if I'm the first one encounterng this. Maybe because it is "just" a Warning and not and Error. I have set Tracy Debugger to strict mode in all of my projects.

On https://www.php.net/manual/en/function.getimagesize.php they explicitly say not to use getimagesize for detecting mime size and recommend https://www.php.net/manual/en/function.finfo-file.php instead.
Is it possible to make the option allowedImageMimeTypes configurable through module settings or to hardcode image/svg+xml as allowed image mime type into the module? This would make it easier to do mime type validation for svg with finfo_file(). Something like

// if (function_exists('exif_imagetype')) { ...
} elseif (function_exists('finfo_file')) {
	$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
	if (in_array(finfo_file($finfo, $imageFile), $allowedImageMimeTypes)) $isValidImage = true;
}
// ...

Or https://www.php.net/manual/en/function.mime-content-type.php is also an option.

Feel free to move this to the JqueryFileuploads thread.

 

  • Like 1
Link to comment
Share on other sites

Hi @gebeer,

Thanks for using MM.

4 hours ago, gebeer said:

There is a PHP Warning related to JqueryFileuploads module

Thanks for reporting this.

4 hours ago, gebeer said:

On https://www.php.net/manual/en/function.getimagesize.php they explicitly say not to use getimagesize for detecting mime size and recommend https://www.php.net/manual/en/function.finfo-file.php instead.

I went through a lot of back and forth with this module in this respect. There were a number of conflicting experiences and/or recommendations out there. For instance:

4 hours ago, gebeer said:
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension

The above is considered by some to be insecure.

4 hours ago, gebeer said:

I had this as an option for a time until I found out it was deprecated. But I have now found it was 'un-deprecated'!

4 hours ago, gebeer said:

Is it possible to make the option allowedImageMimeTypes configurable through module settings or to hardcode image/svg+xml as allowed image mime type into the module? This would make it easier to do mime type validation for svg with finfo_file().

I'll have a think as I am in the process of writing the next version of MM. JFU will no longer be a dependency. In fact, we won't even need jQuery for it.

Link to comment
Share on other sites

On 7/21/2017 at 4:41 AM, kongondo said:

Media Manager version 011  (released 20/07/2017)

Happy to announce the latest release of Media Manager.

Changelog

  1. Fixed bug that caused required Media Manager fields to still be labelled as 'missing required value' even when they were populated.

Sorry to say that this error still occurs in my multilang install using PW 3.0.200 on PHP 7.4 both outside and inside repeaters. Required option set either in field or template context yields the same result.

Problem seems to be with the isEmpty() method in InputfieldMediaManager.module. Specifcally with get_class($value) == 'MediaManagerArray'. In my install get_class($value) returns 'ProcessWire\MediamanagerArray'.

If I replace the check with

		if(is_object($value) && $value instanceof MediaManagerArray && count($value)) $empty = false;

the error is gone.

  • Like 1
Link to comment
Share on other sites

10 hours ago, gebeer said:

Problem seems to be with the isEmpty() method in InputfieldMediaManager.module. Specifcally with get_class($value) == 'MediaManagerArray'. In my install get_class($value) returns 'ProcessWire\MediamanagerArray'.

Thanks for reporting. Looks like a rookie mistake on my part. 

10 hours ago, gebeer said:
if(is_object($value) && $value instanceof MediaManagerArray && count($value)) $empty = false;

Good solution. I'll probably use wireClassName() or wireInstanceOf().

  • Like 1
Link to comment
Share on other sites

14 hours ago, kongondo said:

Good solution. I'll probably use wireClassName() or wireInstanceOf().

I changed my code to use wireInstanceOf(). Works like a charm.

Today another problem surfaced. The MM Settings do not get saved when the core module PagePaths is installed.

Located the cause in ProcessMediaManager.module L156

		$mediaManagerSettings = $this->wire('pages')->get("template=media-manager-settings, parent={$path},include=hidden")->media_manager_settings;

When PagePaths is not installed, the selector returns the page under Admin->Media Manager->Media Manger:Settings just fine.

But with PagePaths installed it returns a NullPage. I found that with PagePaths installed page paths change to also include the language name, but not consistently. My install sets the home URL for the default language to "mydomain.com/en/". The paths that are returned look like

$pages->get('template=media-manager-settings')->path // "/en/processwire/media-manager/media-manager--settings/" (note the '/en/' at the beginning).

$pages->get('name=media-manager')->path // "/processwire/media-manager/"

$config->urls->admin // "/processwire/"

There is the inconsistency. Pages with template admin do not have the language prepended while pages with other templates do. Guess this implementation makes sense. 

When I remove "parent={$path}" from the selector, it works with PagePaths installed. I implemented a quickfix like this

		/******** - MEDIA MANAGER SETTINGS - *******/
		$path = $config->urls->admin . 'media-manager/';
		$selector = "template=media-manager-settings, status<" . Page::statusTrash;
		if(!$this->wire('modules')->isInstalled('PagePaths')) $selector .= ", parent={$path}";
		$mediaManagerSettings = $this->wire('pages')->get($selector)->media_manager_settings;

I left out the "include=hidden" since $pages->get() returns hidden pages by default.

Is "parent={$path}" needed at all, can there be situations where multiple pages with template media-manager-settings are present in the system? Maybe in the Trash. So I handled that situation. 

Please let me know what you think. Thank you.

  • Like 1
Link to comment
Share on other sites

43 minutes ago, gebeer said:

Today another problem surfaced. The MM Settings do not get saved when the core module PagePaths is installed

Great catch! Some users have reported this in the past but never managed to nail it down to PagePaths! 

47 minutes ago, gebeer said:

Please let me know what you think.

I'll have a play and get back to you.

Thanks!

  • Like 1
Link to comment
Share on other sites

@kongondo I have a MM field "icons", allowed media types images. When adding an image via "Add Image", the MM modal pops up and shows all files of type image. I'd like to automatically apply a filter (profile) so that only images with tag 'icon' and extension svg are being listed. Otherwise editors have to manually choose a filter each time.
"Add Image" issues a request which contains a property "filters". But in the field settings I don't see how I could configure which filters to apply.
Is this scenario possible at all?

  • Like 1
Link to comment
Share on other sites

15 hours ago, gebeer said:

But in the field settings I don't see how I could configure which filters to apply.
Is this scenario possible at all?

Hi @gebeer. I have now added this feature to MM 013. I have also added fixes for the issues you've raised above (MM missing required value; PagePaths vs settings issue and finfo_open(FILEINFO_MIME_TYPE) for JqueryFileUpload). Are you able to please test this new version for me before I release it? I have sent you a PM with details. Please note this version needs version 009 of JFU.

Thanks.

Edited by kongondo
Link to comment
Share on other sites

  • 4 weeks later...

Hi,

I once bought a license years ago, now I wanted to install MM again.
I have version 0.12 B, installed with PW 3.0.200 and Jquery File Upload 0.0.9, at first glance everything looks good.

I can upload images in the admin, these also appear, but now the curious, as soon as I click on an image on Edit the image is deleted.

In the logs also appears "rmdir: Unable to rmdir: /site/assets/cache/FileCompiler/".

All this is installed on a local environment with DDEV and PHP 7.4 ...

Any idea what could be the reason for this?

Greetings

Link to comment
Share on other sites

@kongondo Media Manager fields always return a MediaManagerArray, even if Maximum Media Allowed is set to 1. This is not bad at all but it would be great if the logic would follow PageFiles or Page Reference field conventions. There we can choose whether to return an Array or a single object.
So for Media Manager fields it would be nice to have that option, too. Or a default behaviour where fields with max allowed 1 return a single MediaManager object because returning an array doesn't really make sense in that context.

Link to comment
Share on other sites

@kongondoIn my install (PW 3.0.200), Media Manager pages for images and documents get saved under Admin->Media Manager->Media Manager:Audio instead of Media Manager:Image and Media Manager:Document. They have the correct template media-manager-image and media-manager-document, but are under the wrong parent.

What could be the reason?

Link to comment
Share on other sites

On 11/29/2022 at 10:52 AM, gebeer said:

@kongondo Media Manager fields always return a MediaManagerArray, even if Maximum Media Allowed is set to 1. This is not bad at all but it would be great if the logic would follow PageFiles or Page Reference field conventions. There we can choose whether to return an Array or a single object.
So for Media Manager fields it would be nice to have that option, too. Or a default behaviour where fields with max allowed 1 return a single MediaManager object because returning an array doesn't really make sense in that context.

Good idea. I'll and this on my todo list.

On 11/30/2022 at 11:56 AM, gebeer said:

@kongondoIn my install (PW 3.0.200), Media Manager pages for images and documents get saved under Admin->Media Manager->Media Manager:Audio instead of Media Manager:Image and Media Manager:Document. They have the correct template media-manager-image and media-manager-document, but are under the wrong parent.

What could be the reason?

I have no idea. I'll test here and let you know, thanks.

Link to comment
Share on other sites

On 11/23/2022 at 4:02 PM, entschleunigung said:

Hi,

I once bought a license years ago, now I wanted to install MM again.
I have version 0.12 B, installed with PW 3.0.200 and Jquery File Upload 0.0.9, at first glance everything looks good.

I can upload images in the admin, these also appear, but now the curious, as soon as I click on an image on Edit the image is deleted.

In the logs also appears "rmdir: Unable to rmdir: /site/assets/cache/FileCompiler/".

All this is installed on a local environment with DDEV and PHP 7.4 ...

Any idea what could be the reason for this?

Greetings

Hi @entschleunigung. Sorry for a very late reply! I missed your post.

I have no idea what's happening. Are you able to please try with a different ProcessWire version? I don't recall anyone ever reporting a similar issue.

Link to comment
Share on other sites

  • kongondo changed the title to Media Manager Archive
  • kongondo pinned and locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...