Jump to content

Media Manager


kongondo

Recommended Posts

Obviously ImageMagick causes this bug in combination with uploading JPG files, according to the AJAX error message. After deinstalling the IMagick Image Sizer module, uploading JPGs is no problem.

This was my test case:

  1. Uploading the PNG file testupload1png.png
    • With ImageMagick: upload works 👍🏻
    • Without ImageMagick: upload works 👍🏻
  2. Uploading the same image as above converted into the JPG file testupload1jpg.jpg
    • With ImageMagick: upload results in an error message and doesn’t show up in Media Manager. 👎🏻
      AJAX error message: “no decode delegate for this image format `JPEG' @ error/constitute.c/ReadImage/504”
    • Without ImageMagick: upload works 👍🏻
  3. Uploading a second PMG file testupload2png.png
    • With ImageMagick: upload works 👍🏻 AND somehow “pushes” the failed JPG upload into the Media Manager, so now all three uploaded files show up as they should.
    • Without ImageMagick: upload works 👍🏻

I guess I can now either not use ImageMagick (which I just used because my hoster provides it on their servers as a default and it was recommended because of better memory usage). Or I can ask the support of my hoster about this problem.

Link to comment
Share on other sites

Aah, we've got it nailed down at last! The issue, as per the error message and a bit of Googling, is an ImageMagick bug/issue. There are several solutions out there. ImageMagick is a very good library. Before giving up on it, ask your hoster (if you don't have access yourself) to resolve the issue given that there are several solutions out there. Some resolutions simply involve recompiling the library. Here are a few examples of the 'bug':

  1. https://stackoverflow.com/questions/9586048/imagemagick-no-decode-delegate
  2. https://www.imagemagick.org/discourse-server/viewtopic.php?t=12366
  3. https://stackoverflow.com/questions/37594157/imagemagick-no-decode-delegate-for-this-image-format-error-constitute-c-re
  4. http://www.imagemagick.org/discourse-server/viewtopic.php?t=32287
Link to comment
Share on other sites

14 hours ago, tooth-paste said:

Is it possible to only show 'Audio' and hide tabs like 'Documents' and 'Images'?

Yes. However, in the current version, this only works from the inputfield/fieldtype side of things, i.e. when adding media (in media manager library) to a media manager field on a page. When accessing the media library directly, one sees all the 4 media types. However, on the dev version that I'm still working on (it has taken a while I know, but I'd rather get it right than hurry it through since it is a major release), one can control the 'global' visibility of media types as well as at the inputfield/fieldtype level. I'm not sure when the dev version will be ready though. I thought it would have been ready by now but that didn't happen, so, no more ETAs I'm afraid. 

Link to comment
Share on other sites

I'am having some problems to output audio(mp3) files. I've installed Media Manager but don't 'get' it quit yet. The media manager is working and I can upload files.

My template is called 'prekenarchief' and placed the code from the documentation:

  

$media = $page->media;// returns a MediaManagerArray. Needs to be looped through

foreach ($media as $m) {
    echo $m->id;// e.g. 1234 (hidden page in /admin/media-manager/media-parent/)
    echo $m->type;// e.g. 3 (a media of type image) OR 1 (a media of type audio)
    echo $m->typeLabel;// e.g. 'document' (i.e. type would be 2)
    echo $m->title;// e.g. 'My Nice Trip' (whose media file could be my-nice-trip.mp4)
    /*
        @note: 
        - $m->media returns an object;
                   either a ProcessWire Image (for image media) or File object (for audio, document and video media)
        - This means you have access to all the properties of that object,
                   e.g. ext, tags, description, url, filename, basename, width, height,
                        modified, created, filesize, filesizeStr, etc
                        as well as associated methods, e.g. size()
    */ 
    
    echo $m->media->tags;
}

// only output images
foreach ($media as $m) {
    if($m->typeLabel =='image') {
        echo "<img src='" . $m->media->size(100,75)->url . "'><br>";
    }
    
}

// There's also a toString() method so you can do:
echo $page->media;

 

1. What do I need to add to the template to get it to work? I added a new field to the template called 'media', but it doesn't work.

2. Do I need to alter the example code above. For example: Do I need to place an ID. 

 

 

Link to comment
Share on other sites

On 6/26/2018 at 3:35 PM, tooth-paste said:

The media manager is working and I can upload files.

Thanks for the purchase 🙂.

On 6/26/2018 at 3:35 PM, tooth-paste said:

I'am having some problems to output audio(mp3) files.

 

On 6/26/2018 at 3:35 PM, tooth-paste said:

1. What do I need to add to the template to get it to work? I added a new field to the template called 'media', but it doesn't work.

Is media a Media Manager field? If it is not, you need to first create and add a Media Manager field to your  prekenarchief template. You will then need to add the audio files you want to that field. There will be a link in the Media Manager inputfield to your Media Library. You can then use the code above.  This is the most common scenario/usage of Media Manager. You upload media to your Media Manager Library first. You then pick and choose the ones you want to add to a certain page. Finally, you access them using Media Manager API.

Alternatively, you can directly access the media in the Media Library from within your template file without first having to add them to a Media Manager field, e.g.:

/* @note:
  the Media Manager template for audio media is 'media-manager-audio'
  the field with the audio media is 'media_manager_audio'
  in this case, we use include=all OR check_access = 0 since media pages are access-controlled
  admin pages
*/
$media = $pages->find('template=media-manager-audio, include=all, limit=10');
// $media is a PageArray
foreach ($media as $m) {
   // media_manager_image is a Pagefiles so we need to loop through it but..
   // media_manager_audio (also document and video) is a Pagefile. No need to loop
   // example for image media (template = media-manager-image)
   //foreach ($m->media_manager_image as $image) echo $image->url;
   // example for audio/document/video media
   echo $m->media_manager_audio->url;
} 

This is not a common usage, but choose what fits your workflow best.

Edited by kongondo
Code correction
Link to comment
Share on other sites

Thanks for your reply. Something is still not right. Could you check these settings?

I've created a field 'media' and added it to my template.

2085866872_Schermafbeelding2018-06-27om09_01_32.png.5a4fb521901beea9dddb2f3c4bf5ec42.png

 

When I try to add files the 'Insert media' button does not work. I have added files thru upload.

2010269875_Schermafbeelding2018-06-27om09_02_05.thumb.png.5ccfa46bd08c59429d807bce65950814.png

 

 

My template looks like this. But it brings no output to the front-end. Am I doing something wrong?

<?php include("./header.php"); ?>

<div class="container paddingbottom3 paddingtop2">
	<div class="row">
		<div class="col-md-12">
			<div class="row">
				<div class="col-md-6 bglichtgrijs link paddingbottom3">
					<div class="paddingleft4 paddingright5">
						<div class="paddingleft4">
							<h2>Preken</h2>
							
							<?php

								$media = $pages->find('template=media-manager-audio, include=all, limit=10');
								// $media is a PageArray
								foreach ($media as $m) {
								   // media_manager_image is a Pagefiles
									foreach ($m->media_manager_audio as $audio) echo $audio->url;
								}				
							?>
							
						</div>
					</div>
				</div>
				<div class="col-md-6 bggeel link paddingtop2 paddingbottom2">
					<h2 class="colorwit"><?php echo $page->title; ?></h2>
					<br /><br />
					<span class="glyphicon glyphicon-arrow-right colorwit paddingright5"></span><a href="/contact">Neem contact op</a>
				</div>
				
			</div>
		</div>
	</div>
</div>


<?php include("./footer.php"); ?>

 

 

Link to comment
Share on other sites

On 6/27/2018 at 8:08 AM, tooth-paste said:

When I try to add files the 'Insert media' button does not work.

I can tell from your screen grab that the audio media 2212 is unpublished (the crossed eye icon). Unpublished media cannot be added to a Media Manager field, hence why insert media button doesn't do anything. In the upcoming version of MM, you will get a meaningful message/error if you try to add unpublished media to an MM field.

 

On 6/27/2018 at 8:08 AM, tooth-paste said:

My template looks like this. But it brings no output to the front-end. Am I doing something wrong?

Oops, my bad, sorry. Image media would have returned a Pagefiles but audio media should return a Pagefile. So, no need for inner foreach.

$media = $pages->find('template=media-manager-audio, include=all, limit=10');
// $media is a PageArray
foreach ($media as $m) {
	// media_manager_image is a Pagefiles but media_manager_audio is a Pagefile
	// so, no need to loop
	echo $m->media_manager_audio->url;// url to your audio media
}

Just a reminder that the above code is for Direct Access. Use it only if you want to access your media directly from your Media Library without having to add them to any page (i.e., to any MM field). In this case, you do not need the MM media field in your prekenarchief template.

Alternatively, to interact with a MM field, use the code in the documentation.

Edited by kongondo
Code correction
Link to comment
Share on other sites

Hi,

Some time, without a reason, the modulo deletes the images. Do you know why?

I notice when a user enters these pages and in the backend appears the 404 error, I go to see and in fact the images inside the media manager are gone.

Someone knows why and what can I do?

--

Sorry @kongondo!!!! I'm really sorry  I got confused with Media Library module!!! 😨😓 

Edited by MarcoPLY
Link to comment
Share on other sites

4 hours ago, MarcoPLY said:

Some time, without a reason, the modulo deletes the images. Do you know why?

Hi @MarcoPLY,

Please confirm you are talking about the commercial Media Manager module and not another module. Media Manager does not randomly delete images 🙂. I seem to recall you were using other modules for your media needs?

 

  • Sad 1
Link to comment
Share on other sites

Hi kongondo,

we've bought Media Manager under ageny licence and we and our clients are happy with it. But there is actually a problem on a certain page: The integrated upload function no longer works with following exception (from log):

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'heikotel-hotel-am-stadtpark-buffet-2-9840a-1032' for key 'name_parent_id' (in /wire/core/WireDatabasePDO.php line 454) 

How can we fix this?

Another small question: Is there any possibility to get the real url to any media manager document directly from backend? I know how to render the url in my code (by $m->media->url), but some clients want to copy the url from media manager backend into other targets, but didn't found it (and me too). The url can be assembled by analyzing the source code, but this in no option for clients.

Thank you and Best regards,

Thomas.

Link to comment
Share on other sites

@Thomas Scholz,

Welcome to the forums.

11 hours ago, Thomas Scholz said:

we've bought Media Manager under ageny licence and we and our clients are happy with it.

Thanks for the purchase.

11 hours ago, Thomas Scholz said:

But there is actually a problem on a certain page: The integrated upload function no longer works with following exception (from log):

Media are saved as pages, hidden away under Admin. It seems a situation occurred whereby the creation of a media page did not complete and subsequently, the media was re-uploaded and the module tried to create the page again. Since in PW, no pages under the same parent cannot share a name, you get the violation constraint. Was this a media with a big image you were trying to upload? Try deleting the page physically in your page tree: admin > media-manager > media-manager-image > heikohotel-hotel-am-stadtpark-buffet-2-9840a-1032. Make sure to delete it and also empty the trash. If not, you might have to physically delete the page entry in your DB. This situation has happened to me once or twice in the past. I know it is annoying, apologies. On a related note, Media Manager has a setting for handling duplicate media. I'm not sure why that did not kick in before your situation occurred. Most likely, like I said, a page creation did not complete. Let me know if you are still not able to resolve this and I can have a look if the site is online.

 

11 hours ago, Thomas Scholz said:

but some clients want to copy the url from media manager backend into other targets,

I am not sure I understand this. Do you mean, they want to link to media, for example, within text in CKEditor (either as an image or link)? If the answer is yes, just click on the image or link icons in CKEditor and you will see links to pick the media from Media Manager.

Link to comment
Share on other sites

Thank you for your quick answers!

For the first point, the deletion of the concerning page was successful, but was followed by the next similar error with another media page. I will keep trying.

For the second point, the client doesn't need the link in CKEditor, but in Redirects module to set a shorter url for certain pdf documents. So I cant't explain him, how to obtain the original url/path from Media Manager to set as "redirect to".

Link to comment
Share on other sites

29 minutes ago, Thomas Scholz said:

but was followed by the next similar error with another media page. I will keep trying.

Hmm. That's not ideal. This is not how MM usually works 🙂. What's your server environment? ProcessWire version?

30 minutes ago, Thomas Scholz said:

but in Redirects module to set a shorter url for certain pdf documents. So I cant't explain him, how to obtain the original url/path from Media Manager to set as "redirect to".

I have never used the Redirect module. Could you please show me a screenshot of the input where the URL is supposed to go? Do you need the URL or the path?

Link to comment
Share on other sites

For Redirect module, we need the path, e.g. site/assets/files/1234/foo.pdf. This info I can take from source code view or browser dev tools, but for a non-programming-oriented editor ther is no chance to take it directly from Media Manager backend. I would prefer an additional line in document detail view containig the path or url (see attachment).

 

Media Manager Document Detail View Proposal.png

Link to comment
Share on other sites

5 hours ago, Thomas Scholz said:

I would prefer an additional line in document detail view containig the path or url (see attachment)

Excellent idea! I'll add it in the next version of MM. Meanwhile, for now, you can edit the file MediaManagerRender.php and enter the following code after the Filename, i.e. on line #676:

'<span>' . $this->_('URL') . ':</span> ' . $m->httpUrl . '<br>' .

Please note, the output (URL) might be quite long, so the CSS could be off. However, I cannot work on this now since the new version of MM will have a different layout. It will present a challenge though since the descriptions, etc are viewable on hover. When the house is moved away, the overlay goes. This means, it will not be possible to copy the URL. I hope this makes sense. I will have to think more about this.

Link to comment
Share on other sites

  • 3 weeks later...

We've been working on adding the media manger to our new project, but when we create a field to add images/videos to the page, we get the following error in Media Manager:

{"error":true,"message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cmsdev01.field_Product_Assets' doesn't exist"}

When we remove the field from the template (actually we have to delete the field entirely) then the Media Manger will load again and not display that error.  Is there something additional we need to do when we want to start adding Media Manager fields to pages?

Link to comment
Share on other sites

Hi @Karinne Cyphers,

On 7/27/2018 at 1:34 AM, Karinne Cyphers said:

{"error":true,"message":"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cmsdev01.field_Product_Assets' doesn't exist"}

When we remove the field from the template (actually we have to delete the field entirely) then the Media Manger will load again and not display that error.  Is there something additional we need to do when we want to start adding Media Manager fields to pages?

I don't remember ever seeing this error in respect of Media Manager. A couple of questions:

  1. Do other fields, either in the same template or a different one work OK? For instance, text fields, etc
  2. Is the problem with this one template or have you tried a different template?
  3. Maybe there is an issue with the name of your field. Try renaming it to something else and use lower case letters only
  4. MySQL and PHP versions?

If possible, please post a screenshot or animated gif of the error, thanks.

Link to comment
Share on other sites

Thank you for replying... we've identified the issue occurs when we create a Media Manager field with mixed case.  When we create a field that is all lower case the error does not occur and the media manager functions normally.  Everything about the templates function normally, and we can make the media manager field function correctly f it is all lower case.   We've tried different templates and repeaters and the issue always occurs if the field is mixed case.  Our environment is running PHP 7.1.17 and MariaDB 5.6.10.  We had been using mixed case fields as it made it easier to read.  The error occurs whether or not the Manager Manager field has been added to a template or not.

I'm attaching a couple screenshots.  Thank you!

Sketch.png

Sketch (1).png

  • Like 1
Link to comment
Share on other sites

@Karinne Cyphers,

Thanks for the screenshots. They've helped clarify issues.

24 minutes ago, Karinne Cyphers said:

we've identified the issue occurs when we create a Media Manager field with mixed case

I suspected as much given the error MySQL was throwing.

The error itself is originating from  ProcessPageLister (a core module) which Media Manager extends and uses to fetch and display media pages. As far as I can remember, ProcessWire only allows lower case letters for field names. Going by your screenshot though, it seems this changed sometime back. 

Back to your issue, the error is a ProcessWire error and not Media Manager's.  I'm not sure whether it should be filed as a ProcessWire bug (specific to your server environment, maybe) since it now seems upper case letters are allowed in field names. I'll try and find out.

 

Edited by kongondo
  • Like 1
Link to comment
Share on other sites

21 minutes ago, kongondo said:

As far as I can remember, ProcessWire only allows lower case letters for field names.

I think it has always said this:

"Use only ASCII letters (a-z A-Z), numbers (0-9) or underscores."

I think it's likely we've just always assumed lowercase only because names suggest lowercase vs labels/titles which is where you expect difference cases, spaces, special chars etc.

  • Like 1
Link to comment
Share on other sites

32 minutes ago, adrian said:

I think it has always said this:

"Use only ASCII letters (a-z A-Z), numbers (0-9) or underscores."

I think it's likely we've just always assumed lowercase only because names suggest lowercase vs labels/titles which is where you expect difference cases, spaces, special chars etc.

Thanks Adrian. This got me more curious because I vaguely remember having a talk about lower case vs upper case. So, I went back and checked, all the way from 2.2 up to and including 2.7.3. It was only lower case in those versions. So, this must be a 3.x introduction.

 

  • Like 2
Link to comment
Share on other sites

3 minutes ago, kongondo said:

Thanks Adrian. This got me more curious because I vaguely remember having a talk about lower case vs upper case. So, I went back and checked, all the way from 2.2 up to and including 2.7.3. It was only lower case in those versions. So, this must be a 3.x introduction.

 

Apologies - you are indeed correct.

I can't imagine why it would actually have been changed - not sure why you'd need uppercase chars in a field name, but the description of what is allowed certainly has changed.

https://github.com/ryancramerdesign/ProcessWire/blob/a210ba0b5ea67e56fef8a27a620bcfa6f96ca0b8/wire/modules/Process/ProcessField/ProcessField.module#L949

https://github.com/processwire/processwire/blob/48fe0769a4eb3d0f5b4732fd01b4b4ed8262d952/wire/modules/Process/ProcessField/ProcessField.module#L1196

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
×
×
  • Create New...