You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours:
Monday To Friday
From 09:00 To 17:00 Europe/London (BST)

Please post your question in the Forum and we will get back to you as soon as we can.

  Wednesday, 06 October 2021
  3 Replies
  552 Visits
Hello,

I have created my own component and use the form field in the backend:

<field
name="file"
type="media"
label="COM_TOOLBOXHEKA_FIELD_FILE_LABEL"
description="COM_TOOLBOXHEKA_FIELD_FILE_DESC"
preview="false"
class="span12"
hint="text"
accept="/image/downloads/"
showon="type:1"
/>


In the JCE configuration I have activated both parameters in Profile > Plugin Settings > Media Field Options, so that when using the form field the JCE Media Browser is started and I can select or upload a file.

But I can only select or upload files with the extension jpg, jpeg, png, apng, gif, webp, avif, although the extension pdf is entered in the JCE configuration > plugin settings > picture manager. In the global Joomla media configuration, PDF is also entered as a permitted file extension, image ending and file type.

I know there is a hack where you can enter additional file types in com_media. But since this cannot be updated.

I also read somewhere that the property should be added to the form field.

<field
name="file"
type="media"
label="COM_TOOLBOXHEKA_FIELD_FILE_LABEL"
description="COM_TOOLBOXHEKA_FIELD_FILE_DESC"
preview="false"
class="span12"
hint="text"
accept="/image/downloads/"
showon="type:1"
filter="pdf"
/>


But even then I cannot select or upload a PDF.

Does anyone know a solution to this?
2 weeks ago
·
#109035
Hello, I was able to solve my problem!

Step 1:
I copied the file 'plugins / system / jce / fields / mediajce.php' to 'administrator / components / com_mycomponent / models / fields'

Step 2:
Change my form field in:

<field
name="file"
type="mediajce"
label="COM_TOOLBOXHEKA_FIELD_FILE_LABEL"
description="COM_TOOLBOXHEKA_FIELD_FILE_DESC"
preview="false"
class="span12"
directory="/image/downloads/"
showon="type:1"
/>


Now the media field is not an image manager but a file manager and can be set via the profile in the JCE configuration.
teccrow marked this post as Resolved — 2 weeks ago
2 weeks ago
·
#109040
You can set specific filetypes for a mediajce field by using a mediatype attribute, eg:


<field
name="file"
type="mediajce"
label="COM_TOOLBOXHEKA_FIELD_FILE_LABEL"
description="COM_TOOLBOXHEKA_FIELD_FILE_DESC"
preview="false"
class="span12"
directory="/image/downloads/"
showon="type:1"
mediatype="files"
/>


Unfortunately this does not work for a core "media" field.

In a similar way to what you have done for the mediajce.php field, you can create an override of the Joomla core media field, and change the url in that field so that the view=images part becomes view=files.

See this post - https://www.joomlacontenteditor.net/support/forum/108490-can-t-upload-pdf-with-jce-in-repeatable-field#reply-108496

Just because you're not paranoid doesn't mean everybody isn't out to get you.

2 weeks ago
·
#109041
Sorry, I forgot to write that I changed the file 'administrator / components / com_mycomponent / models / fields / mediajce.php':


public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);

if ($result === true) {
//$this->mediatype = isset($this->element['mediatype']) ? (string) $this->element['mediatype'] : 'images';
$this->mediatype = "files";
}

return $result;
}


This is how it works very well in my component!
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!