Open szepeviktor opened 8 years ago
Wait! For image type:
The supported attributes are, 'title', 'alt', 'width', 'height', 'caption', 'id', 'align', and 'link'.
For media type only
The supported attributes are, 'id', 'caption', and 'description'.
Would it be possible to support all data that can be set in the "Insert Media" dialog? 'title', 'alt', 'width', 'height', 'caption', 'id', 'align', 'link' and 'size' also, as it is available.
Is there a way to display preview for media field type?
There is no preview option for the media
field type at the moment.
Would it be possible to support all data that can be set in the "Insert Media" dialog?
Not sure. I'll check.
When the media uploader dialog is closed, an attachment object is passed to the JavaScript method (https://github.com/michaeluno/admin-page-framework/blob/e23d481d2f432bf1e791e17fb7997b33b606a8e1/development/factory/_common/form/field_type/AdminPageFramework_FieldType_media.php#L259) and its attributes
property holds the following members (the values are an example).
alt: "Alt value"
author: "1"
authorName: "admin"
caption: "This is a caption."
compat: Object
date: Fri Jan 29 2016 02:22:37 GMT+0900 (Tokyo Standard Time)
dateFormatted: "January 29, 2016"
description: "Descriptions!"
editLink: "http://.../wp-admin/post.php?post=2143&action=edit"
filename: "Penguins.jpg"
filesizeHumanReadable: "760 kB"
filesizeInBytes: 777835
height: 768
icon: "http://.../wp-includes/images/media/default.png"
id: 2143
link: "http://.../penguins/"
menuOrder: 0
meta: false
mime: "image/jpeg"
modified: Sat Feb 20 2016 10:16:24
name: "penguins"
nonces: Object
orientation: "landscape"
sizes: Object
status: "inherit"
subtype: "jpeg"
title: "Penguins"
type: "image"
uploadedTo: 0
url: "http://.../wp-content/uploads/2016/01/Penguins.jpg"
width: 1024
I don't see size
and align
in that property object so it is hard to set them to the input fields of the form created by the framework.
If you know a way to retrieve them, let me know.
Coudl it be sizes: Object
?
The sizes
property looks like this and no information for which one the user selected.
full: Object
height: 768
orientation: "landscape"
url: "http://.../wp-content/uploads/2016/01/Penguins.jpg"
width: 1024
__proto__: Object
large: Object
height: 469
orientation: "landscape"
url: "http://.../wp-content/uploads/2016/01/Penguins-1024x768.jpg"
width: 625
__proto__: Object
medium: Object
height: 225
orientation: "landscape"
url: "http://.../wp-content/uploads/2016/01/Penguins-300x225.jpg"
width: 300
__proto__: Object
thumbnail: Object
height: 150
orientation: "landscape"
url: "http://.../wp-content/uploads/2016/01/Penguins-150x150.jpg"
width: 150
You can check the object by inserting console.log( oAttachment );
after the highlighted line posted in the previous reply. You'll find the attributes
property.
I've roughly searched the web and could not find a proper way to retrieve all the selected options in the media uploader form including the ones you requested such as size
and alignment
. It's not impossible to code to retrieve those but if there is already an establish method to retrieve them, it should be used. Let me know if you know it.
Should I use
field_{instantiated class name}_{section id}_{field ID}
to put the media link into the input's value?Is there a way to display preview for media field type?