{"id":653,"date":"2018-04-23T15:56:12","date_gmt":"2018-04-23T15:56:12","guid":{"rendered":"https:\/\/buddydev.com\/mediapress\/?p=653"},"modified":"2018-04-23T15:56:20","modified_gmt":"2018-04-23T15:56:20","slug":"importing-file-mediapress-gallery","status":"publish","type":"post","link":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/","title":{"rendered":"Importing a file to MediaPress Gallery"},"content":{"rendered":"<p>If you want to import a local file from the server to MediaPress Gallery, we provide an api for it.<\/p>\n<p>With MediaPress 1.3.6 and above, we have an API to import a local file from server directory\u00a0 to MediaPress .<\/p>\n<p><strong>mpp_import_file( $file, $gallery_id, $overrides = array() )<\/strong><\/p>\n<p><strong>Parameters:-<\/strong><\/p>\n<ul>\n<li>$file(required)(string):- Absolute path of the file to be imported.<\/li>\n<li>$gallery_id(required)(integer):- a valid MediaPress gallery id.<\/li>\n<li>$overrides(optional)(array):- Override any extra property of the media.<\/li>\n<\/ul>\n<p><strong>Return:-<\/strong><\/p>\n<p>media id on success or WP_Error object on failure.<\/p>\n<p>Example:-<\/p>\n<p>mpp_import_attachment(&#8216;\/home\/xyz\/whaever\/nature.jpg, 32);<\/p>\n<p>That will import nature.jpg file to our gallery. The status is inherited from the gallery. You can override it using the overrides array.<\/p>\n<p>What Happens Internally:-<\/p>\n<ul>\n<li>We test if the file exists and is readable.<\/li>\n<li>We test for the validity of gallery<\/li>\n<li>If both are valid, we test if the media specified by the attachment is a valid type of media for MediaPress(e.g allowed file type).<\/li>\n<li>If all is well, we check that the gallery type can contain media of the given type.<\/li>\n<li>If we reach here, we copy the file to the MediaPress&#8217;s gallery directory.<\/li>\n<li>We create a new media and save the media details(title, type etc) to database.<\/li>\n<li>If everything goes well, return the media id which is same as the attachment id.<\/li>\n<li>If any of the above steps go wrong, we return an instance of WP_Error detailing the problem.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to import a local file from the server to MediaPress Gallery, we provide an api for it. With MediaPress 1.3.6 and above, we have an API to import a local file from server directory\u00a0 to MediaPress . mpp_import_file( $file, $gallery_id, $overrides = array() ) Parameters:- $file(required)(string):- Absolute path of the file to &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4557],"tags":[],"class_list":["clearfix","post-653","post","type-post","status-publish","format-standard","hentry","category-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev\" \/>\n<meta property=\"og:description\" content=\"If you want to import a local file from the server to MediaPress Gallery, we provide an api for it. With MediaPress 1.3.6 and above, we have an API to import a local file from server directory\u00a0 to MediaPress . mpp_import_file( $file, $gallery_id, $overrides = array() ) Parameters:- $file(required)(string):- Absolute path of the file to ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/\" \/>\n<meta property=\"og:site_name\" content=\"MediaPress | BuddyDev\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/bpdev\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-23T15:56:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-23T15:56:20+00:00\" \/>\n<meta name=\"author\" content=\"Brajesh Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sbrajesh\" \/>\n<meta name=\"twitter:site\" content=\"@buddydev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brajesh Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/\",\"url\":\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/\",\"name\":\"Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev\",\"isPartOf\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/#website\"},\"datePublished\":\"2018-04-23T15:56:12+00:00\",\"dateModified\":\"2018-04-23T15:56:20+00:00\",\"author\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\"},\"breadcrumb\":{\"@id\":\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/buddydev.com\/mediapress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Importing a file to MediaPress Gallery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#website\",\"url\":\"https:\/\/buddydev.com\/mediapress\/\",\"name\":\"MediaPress | BuddyDev\",\"description\":\"The Best Media Gallery Plugin For BuddyPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/buddydev.com\/mediapress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb\",\"name\":\"Brajesh Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/image\/\",\"url\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"contentUrl\":\"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon\",\"caption\":\"Brajesh Singh\"},\"sameAs\":[\"http:\/\/buddydev.com\/members\/sbrajesh\/\",\"https:\/\/x.com\/sbrajesh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/","og_locale":"en_US","og_type":"article","og_title":"Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev","og_description":"If you want to import a local file from the server to MediaPress Gallery, we provide an api for it. With MediaPress 1.3.6 and above, we have an API to import a local file from server directory\u00a0 to MediaPress . mpp_import_file( $file, $gallery_id, $overrides = array() ) Parameters:- $file(required)(string):- Absolute path of the file to ...","og_url":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/","og_site_name":"MediaPress | BuddyDev","article_publisher":"https:\/\/www.facebook.com\/bpdev","article_published_time":"2018-04-23T15:56:12+00:00","article_modified_time":"2018-04-23T15:56:20+00:00","author":"Brajesh Singh","twitter_card":"summary_large_image","twitter_creator":"@sbrajesh","twitter_site":"@buddydev","twitter_misc":{"Written by":"Brajesh Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/","url":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/","name":"Importing a file to MediaPress Gallery &#8226; MediaPress | BuddyDev","isPartOf":{"@id":"https:\/\/buddydev.com\/mediapress\/#website"},"datePublished":"2018-04-23T15:56:12+00:00","dateModified":"2018-04-23T15:56:20+00:00","author":{"@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb"},"breadcrumb":{"@id":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/buddydev.com\/mediapress\/media\/importing-file-mediapress-gallery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/buddydev.com\/mediapress\/"},{"@type":"ListItem","position":2,"name":"Importing a file to MediaPress Gallery"}]},{"@type":"WebSite","@id":"https:\/\/buddydev.com\/mediapress\/#website","url":"https:\/\/buddydev.com\/mediapress\/","name":"MediaPress | BuddyDev","description":"The Best Media Gallery Plugin For BuddyPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buddydev.com\/mediapress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/4ebf5f3e519f8cbddc6583e182dbe4fb","name":"Brajesh Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buddydev.com\/mediapress\/#\/schema\/person\/image\/","url":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","contentUrl":"\/\/www.gravatar.com\/avatar\/2106622ee90d53d15ac1402806616aca?s=96&#038;r=g&#038;d=identicon","caption":"Brajesh Singh"},"sameAs":["http:\/\/buddydev.com\/members\/sbrajesh\/","https:\/\/x.com\/sbrajesh"]}]}},"_links":{"self":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/comments?post=653"}],"version-history":[{"count":1,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/653\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/posts\/653\/revisions\/654"}],"wp:attachment":[{"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/media?parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/categories?post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buddydev.com\/mediapress\/wp-json\/wp\/v2\/tags?post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}