Jump to content

besrwordt

Members
  • Content Count

    4
  • Joined

  • Last visited

Posts posted by besrwordt


  1. On 1/28/2019 at 10:18 PM, kongondo said:

    @besrwordt,

    Do you have a current Media Manager subscription? makeBlankItem() is implemented in the latest Media Manager (version 012, soon coming out of beta). However, you can still import from one MM field to another. A MM field behaves like PageArrays (WireArrays).  

    Yes i have. Will try that for sure!

    A Media Manager field stores only two pieces of data; the (page) ID of the media being referenced and the media type (1=audio; 2=document; 3=image; 4=video; 3x=image variation). There's two ways you can go about exporting/importing from one field to the other. The second way is easiest if you need to import everything from one field to another, no questions asked. The first method allows fine control, e.g. if you want to skip certain media types. In the examples below, media_export is the Media Manager field with the media you want to copy over/merge with a second Media Manager field. media_import is the second Media Manager field into which media is being imported/copied over.

    Method One: Loop through each media in the Media Manager field you are exporting from

    
    // page with mm field we are importing into (media_import)
    $p = $pages->get(1234);
    
    // page with mm field we are exporting from (media_export)
    foreach ($page->media_export as $m ) {
        // @note: here you can skip media you don't want to export
        // instance of new MediaManager()
        $mm = new MediaManager();
        // populate the MediaManager object properties with required data (media id and type)
        $mm->id = $m->id;
        $mm->type = $m->type;
        // import/add the media to the 2nd mm field (media_import)
        $p->media_import->add($mm);
    }
    
    // output formatting of
    $p->of(false);
    // save only the media manager field (page with import mm field)
    $p->save('media_import');
    // revert output formatting back on
    $p->of(true);

     

    Method Two: Import everything at once

    
    // page with mm field we are importing into (media_import)
    $p = $pages->get(1234);
    // import all the media in the 1st mm field (media_export) into the 2nd mm field (media_import)
    $p->media_import->import($page->media_export);
    // output formatting of
    $p->of(false);
    // save only the media manager field (page with import mm field)
    $p->save('media_import');
    // revert output formatting back on
    $p->of(true);

     

    Note that all WireArray behaviour apply. For instance, you might want to first experiment in cases where your 2nd Media Manager field (media_import) already has some media which may or may not be present in the first Media Manager field. 

    Great, Thanks!!!

     


  2. @kongondo Another thing: how would i go about to merge 2 mediamanager fields via API... if i add the media from one field to another i get the Class 'MediaManagerArray' doesn't yet implement method 'makeBlankItem() error ...

                foreach ($page->mm-field->media as $t-media ){
                    $_another_mmmedia_field.=$t-media;
                }

    ...

     


  3. Hi,

    i have trouble getting images resized in the listerPro module from Ryan. He asks if the MediaManager module implements the markupValue() method?!

    To clarify in The listerPro module can list fields such as images of records. in order to produce a nice list / table it can resize the images on the fly ... thumbnails of 80x80 or what ever setting you whish.

    In my setup this is not working (mediamanager field, single instance, only image allowed) and Ryan suggests the markupValue() is probably not implemented.

    I my self thought there might be an abstraction depth problem as on the normal imagefield one interacts with the field. In the mediamanager one interacts with the $field->media object ... one level down ...

×
×
  • Create New...