- Posts: 19
Question
Error in adding media type
- kdmiller45
-
Topic Author
- Offline
- New Member
-
Less
More
1 month 3 weeks ago #116636
by kdmiller45
Error in adding media type was created by kdmiller45
I am trying to add a .pdf as a media type and get the following error when I try to save it
SyntaxError: Unexpected token '<', "
Using version Website 2.2.6
SyntaxError: Unexpected token '<', "
Using version Website 2.2.6
Please Log in or Create an account to join the conversation.
- bertkoor
-
- Offline
- Platinum Member
-
- Greetings from Utrecht, Holland
1 month 3 weeks ago - 1 month 3 weeks ago #116637
by bertkoor
stamboom.BertKoor.nl runs on webtrees v2.2.6
Replied by bertkoor on topic Error in adding media type
I'm not sure what you have done exactly. Is there a stacktrace with that error message? Have you changed some code? Can you share a screenprint?
I don't think you've done the right thing. In webtrees the media type describes the type of content, not the file extention. For example the media type "picture" can be used with file extensions .png, .jpg. .bmp, etc etc, including .pdf
The .pdf file extension is already supported as a "mime type".
See github.com/fisharebest/webtrees/blob/7ed...fbb/app/Mime.php#L55
When adding a .pdf as a media object, I'd suggest "document" or "electronic" as the media type. The values are defined here:
github.com/fisharebest/webtrees/blob/7ed...rceMediaType.php#L80
I don't think you've done the right thing. In webtrees the media type describes the type of content, not the file extention. For example the media type "picture" can be used with file extensions .png, .jpg. .bmp, etc etc, including .pdf
The .pdf file extension is already supported as a "mime type".
See github.com/fisharebest/webtrees/blob/7ed...fbb/app/Mime.php#L55
When adding a .pdf as a media object, I'd suggest "document" or "electronic" as the media type. The values are defined here:
github.com/fisharebest/webtrees/blob/7ed...rceMediaType.php#L80
stamboom.BertKoor.nl runs on webtrees v2.2.6
Last edit: 1 month 3 weeks ago by bertkoor.
Please Log in or Create an account to join the conversation.
- hermann
-
- Away
- Elite Member
-
1 month 3 weeks ago #116643
by hermann
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu
Replied by hermann on topic Error in adding media type
The reason for that error message is that webtrees delivers JSON when html is expected. But the reason behind that is not clear.
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu
Please Log in or Create an account to join the conversation.
- bertkoor
-
- Offline
- Platinum Member
-
- Greetings from Utrecht, Holland
1 month 3 weeks ago #116644
by bertkoor
stamboom.BertKoor.nl runs on webtrees v2.2.6
Replied by bertkoor on topic Error in adding media type
Good thinking, Hermann!
Here's a short guide to analyse with your web browser what has happened.
webtrees.net/faq/xhr/
Although this might not have been an XHR request, the method to see request & response details is similar.
It could be that the .pdf was too large.
webtrees.net/faq/file-upload/
Here's a short guide to analyse with your web browser what has happened.
webtrees.net/faq/xhr/
Although this might not have been an XHR request, the method to see request & response details is similar.
It could be that the .pdf was too large.
webtrees.net/faq/file-upload/
stamboom.BertKoor.nl runs on webtrees v2.2.6
Please Log in or Create an account to join the conversation.
- thomas52
-
- Offline
- Premium Member
-
- Western North Carolina
4 weeks 2 days ago #116824
by thomas52
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Replied by thomas52 on topic Error in adding media type
I get same with a .jpg ... (possibly Cloudflare error?)
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Please Log in or Create an account to join the conversation.
- hermann
-
- Away
- Elite Member
-
4 weeks 1 day ago #116829
by hermann
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu
Replied by hermann on topic Error in adding media type
No, that is not related to Cloudflare, the reason is in webtrees. Please, deactivate your custom modules as a first step. For example rename the folder modules_v4 to modules_v9, then test again.
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.6 (100 custom modules installed, PHP 8.4.10, MariaDB 10.6) @ ahnen.hartenthaler.eu
Please Log in or Create an account to join the conversation.
- thomas52
-
- Offline
- Premium Member
-
- Western North Carolina
4 weeks 1 day ago #116831
by thomas52
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Replied by thomas52 on topic Error in adding media type
After renaming Models_v4 per your instructions, I still get the same error message: SyntaxError: Unexpected token '<', "
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Please Log in or Create an account to join the conversation.
- bertkoor
-
- Offline
- Platinum Member
-
- Greetings from Utrecht, Holland
4 weeks 1 day ago #116833
by bertkoor
stamboom.BertKoor.nl runs on webtrees v2.2.6
Replied by bertkoor on topic Error in adding media type
Well, I tested uploading some random image to your site, and that worked. So it's either something in this specific image, or it's the network route.
You can use the webtrees demo site (login with 'editor' - 'editor') to test uploading there. Or I can test it with your specific image on your site if you send it to me. Maybe I spot something you missed...
You can use the webtrees demo site (login with 'editor' - 'editor') to test uploading there. Or I can test it with your specific image on your site if you send it to me. Maybe I spot something you missed...
stamboom.BertKoor.nl runs on webtrees v2.2.6
Please Log in or Create an account to join the conversation.
- thomas52
-
- Offline
- Premium Member
-
- Western North Carolina
4 weeks 11 hours ago #116836
by thomas52
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Replied by thomas52 on topic Error in adding media type
I cancelled CloudFlare, and everything is back to normal. Now I need to deal with the bots.
Research is what I’m doing when I don’t know what I’m doing – Wernher von Braun
Please Log in or Create an account to join the conversation.