Upload product video

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #305466

Hi,

We are trying add custom field of type of product so we could upload product video for each product and show it in html5 video attribute like this:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
</video>

Everything would be fine but we miss some custom field for video upload only. It would be great to have it. So that video file would be saved in seperate video folder inside hikashop upload folder and later we could access it with some simple php code... I think many hikashop users do have videos and not only images for products....

Unless there is other way to upload video without using safe folder (which purpose is different) as this is where all uploads goes if using field type -> file

Adding video link via wysiwyg editor is not and option as "video" atrribute will be removed by editor and it is time consuming to add such links for every product created.

Please advise?

Kind Regards

Last edit: 4 years 11 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
4 years 11 months ago #305483

Hi,

1. What could be done in the future is to have an option in the custom file/ajax file fields to upload to another folder than the current one. But that's not really a problem. Another solution would be to have a "display template" option where you could have your own HTML with a tag for the file link. That way, even if the file would be in the secure folder, if the user seeing the field has access to the link, the link would work.

2. With what you have right now in the custom fields, the simplest would be to edit the view file displaying the custom field value and add some str_replace on the display function call of the custom field to change the current link to have instead a video tag.
So for example, for the display of the custom product fields on the product page, you would change the code:

<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
to something like that:
<?php echo str_replace(array('<a target="_blank" class="hikashop_custom_file_link" href="', '</a>'),array('<video width="320" height="240" controls><source type="video/mp4" src="', '</video>'),$this->fieldsClass->show($oneExtraField,$value)); ?>
in the view file show_block_custom_main.php via the menu Display>Views.

The following user(s) said Thank You: kyratn

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #305488

Hi,

1. That's indeed would be a great solution! Please consider it adding...This would allow to have different upload folders per custom field i guess. Also if product deleted it would be good if that file would be deleted too.

2. Thank you

Kind Regards

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #305505

Hi,

Could someone explain a bit how access is working for safe folder? Because i could easiely access my custom field in custom module with:

$productClass = hikashop_get('class.product');
$product=$productClass->get($product_id);
$video = $product->product_video;

But this doesn't work in show_default view file. So i go a bit confused cause i thought i still would have to use "fieldsClass->show($oneExtraField,$value)" else it won't be accessible...

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #305510

Please ignore, found it :)

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
4 years 11 months ago #305506

Hi,

While you do have the value of the filename in $product->product_video the file is stored in media/com_hikashop/upload/safe/ which has a .htaccess file which denies its access.
If you remove that .htaccess, or change the upload secure folder setting to a folder without an htaccess file, then you'll be able to directly access all the files from that folder. If you only upload such files that you want freely accessible, then you could do either of these. However, if you have also paid downloads that you don't want to be directly accessible, then you shouldn't do that and only access the files through the link generated by the field system.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 11 months ago #305539

Hi,

Thanks for explanation Nicolas. I see how it works now.
Looking into future, we possible could use safe folder so as for now we will stick with accessing file via field system.

However it would be greate if you could add possibility to change upload folder for custom field with type of file or any other solution would be great :)

Have a great weekend

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
4 years 11 months ago #305542

Yes, thanks for your feedback. I've added something about that on our todo list.

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 3
4 years 6 months ago #310831

Is this still being worked on?

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
4 years 6 months ago #310839

Are you talking about the possibility to change the upload folder for the custom field ?
We looked into it, but the change is not that easy to make as it has implications for other areas of HikaShop using the AJAX uploader. So for now, we've put that on hold.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 6 months ago #310862

Hi,

Maybe it would be easier to add what i suggested in my first message of this topic?

We still use safe folder "work around" but biggest issue is that it is safe folder, video file is not deleted if product is. At some time you need to go to clear it manually, which is time consuming. So as for now we are uplading videos for our best converting products only.

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
4 years 6 months ago #310865

Hi,

The thing is that the file in the safe folder might be used by something else (another product custom field or another product or another type of custom field or even as a file of another product).
That's a lot of different things to check to make sure that we're not deleting something that it used by something else.

Please Log in or Create an account to join the conversation.

Time to create page: 0.083 seconds
Powered by Kunena Forum