SWFobject flashvars embedding issue - swfobject

Implementing EasyCaptions on my WordPress blog and I’ve hit a brick wall. Any help would be appreciated. I’m using SWFobject to embed videos. I’ve pasted this code: http://pastebin.com/0ZMSr0Bz into my header.php and this embed code in my posts:
<video id="video-html5" width="480" height="320" controls="controls"
source src="[url to video]" />
</video>
The problem is the implementation only works for the video defined here:
var flashvars = { file:'[video url]', ...
All other videos embeds do not work. I've tried using a playlist but that did not solve the problem. How do I solve this? Do I need additional JS or PHP code to add to the file parameter?

[edited post]
I just re-read your question and looked at the pastebin. The video URL you're using is an HTML file: http://vidbull.com/embed-iqkhawkkx1rn-640x318.html. You can't load an HTML file as a video.
Try it again using a proper video URL (MP4, F4V, OGG, etc).
-- UPDATED based on comment from OP --
The issue is that you're hard-coding the video URL in your WordPress header. What you'll need to do is use a variable instead. I suggest using WordPress' "shortcode" API, which will enable you to pass variables via a custom shortcode.
Define your shortcode in WordPress, something like:
//[easycaptions]
function embed_easycaptions( $atts ){
//your custom PHP code here, using the passed $atts
}
add_shortcode( 'easycaptions', 'embed_easycaptions' );
Then when authoring your WordPress blog post, you add the custom shortcode where desired, such as
[easycaptions url='http://localhost/wordpress1/wp-content/uploads/2012/10/Sheldon-in-a-Dress.mp4']
Check out the Shortcode API page for instructions and examples. It's a pretty powerful system.

The solution lies in NOT hard-cording the video url in the header.php. Here is what worked to solve this. I first created a custom field in wordpress, named it thinema, and then set the value of the custom field to be the embedded video url in the post. Then edited this code into my header.php
flashvars = { file: '<?php echo get_post_meta(get_the_ID(), thinema, true); ?>'...
I've updated the code in pastebin. Hope this is of use to someone! You can view the implementation here.

Related

How do I use JSON as a source of content in a 2sxc app?

I have a JSON file that has some simple fields and content. I want to make a 2sxc app that simply lists out the content of the JSON file using C# Razor. (Ultimately this json file will be hosted elsewhere).
Ideally, the content will be rendered as simple HTML in the page that I can see when I click view source in the browser so I know it's SEO friendly.
Is this possible? What kind of code would I need to do this?
I was able to figure it out using this example: https://2sxc.org/dnn-tutorials/en/razor/json/home
So my code looked something like this:
#inherits ToSic.Sxc.Dnn.RazorComponent
#inherits Custom.Hybrid.Razor12
#{
var someJson = System.IO.File.ReadAllText(App.PhysicalPath + "/json/UseCases.json");
var thing = AsDynamic(someJson);
}
#foreach(var useCase in thing.UseCases) {
#useCase.URLPart
<h3>Name: #useCase.Name</h3>
<h4>#useCase.Domain</h4>
<p>#useCase.ShortDescription</p>
#Html.Raw(useCase.Highlights)
}

In WagTail, how do you display a full document url for document links embedded in richtext?

I'm setting up a wagtail site which needs to display all links as full urls since the pages will also be used as email templates.
Wagtail version 2.5.1
My main issue is document links which are embedded in RichTextFields. The current work around is to have them inserted as external links after they upload the documents.
I've looked at features.register_link_handler but am unclear on how to deal with Document links. I'm assuming that it will need to be in wagtail_hooks.py register_rich_text_features somehow.
I ended up creating a register_rich_text_features link handler for this in wagtail_hooks.py
class DocumentFullLinkHandler(DocumentLinkHandler):
#classmethod
def expand_db_attributes(cls, attrs):
try:
document = cls.get_instance(attrs)
current_site = Site.objects.get_current()
document_url = (
document.url
if document.url.startswith(settings.PATH_PREFIX)
else f"{settings.PATH_PREFIX}{document.url}"
)
full_url = f"https://{current_site.domain}{document_url}"
return f'<a href="{escape(full_url)}">'
except (ObjectDoesNotExist, KeyError):
return "<a>"
The real answer is to Upgrade to Wagtail 2.7 and then set
WAGTAILDOCS_SERVE_METHOD = "direct" in the settings.
This will provide the direct document when using remote storage.
#sw12k I tried to apply your same solution and I couldn't make it work, but... I think I found a much simpler solution that actually made the trick.
In the html template, when you render your RichTextField I moved from:
{{ page.description|safe }}
to this:
{{ page.description|richtext }}
And now document links are well formatted and download links work fine.
Hope it helps.

Umbraco 8 + React - How to access image

Trying to pull an image from Umbraco and display it using React.
I can pull all the text by doing this for example -
{String(this.props.data['carouselUnderImageText'])}
{String(this.props.data['carouselLink'])}
But when doing an image -
<img src={this.props.data["carouselImage"]} or <img src={String(this.props.data["carouselImage"])} />
Those two won't work, it seems to return me the url umb://media/8990dd19cfb746e0bea4baec5df20d01
Any ideas on how to solve this? I have not found enough documentation to fix this issue when using Umbraco with React.
If there is anything else I can show in order to help answer this question just put it in the comments and I will update the question.
Many Thanks in advance.
You can get the IPublishedContent of the image file by using the TypedMedia function in the Umbraco Helper, you can then access the images URL to be passed through to react.
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
Udi.TryParse(carouselImage, out var carouselImageUdi); // this parses the umb://media string into a UDI to be used in TypedMedia.
var imageUrl = umbracoHelper.TypedMedia(carouselImageUdi).Url;

angularJS - loading a web page inside a div tag

I have seen this question in STO but could not find a proper answer.
I am using angular 1.0 and sending an AJAX request to server to get a list of URLs like below format:
https://www.abc.info/tawasol-news/20830168
https://www.abc.info/tawasol-news/20830169
https://www.abc.info/tawasol-news/20830174
and I want to load these URLs in a set of div tags down another.
but I can not see a clear solution how achieve that. please help to to load these URLs inside a div where we can scroll and view item by item.
Thank you
One solution is using object element in your HTML (div).
<object type="text/html" data="your url"></object>
See Mozilla documentation for object here.

Show multiple pages of PDF with Angular and pdf.js

I want to show PDFs in my angular application. It should be possible to show multiple pages at once and to search inside the PDF.
I tried angularjs-pdf to do so, but it lacks these features. Is there a angular wrapper for pdf.js that can do this? Or can somebody get me startet on how to implement pdf.js in my angular application without a wrapper?
Assuming this statement:
"I want to show PDFs in my angular application"
Anyone searching for this, could ought to check out ng2-pdf-viewer, for more information on this module, can check this out ng2-pdf-viewer PdfShowcase
Basically, this module could somewhat allow one to display more than one PDF in a single screen.
app.component.ts
// Declare the pdf as an empty array
pdfs = [];
// Assuming requesting PDFs from server through MVC style
getPdfs(){
this.getPdfService.getPdfs().subscribe(response => {
response.body.forEach((value, index) => {
this.pdfs.push({
id: index,
obj: window.URL.createObjectURL(value);
});
});
});
}
app.component.html
<div *ngFor="let pdf of pdfs, index as i;">
<div *ngIf="pdf[i]">
<pdf-viewer
[rotation]="0"
[original-size]="true"
[show-all]="true"
[fit-to-page]="true"
[zoom]="0"
[zoom-scale]="'page-width'"
[stick-to-page]="true"
[render-text]="false"
[external-link-target]="'blank'"
[autoresize]="true"
[show-borders]="true"
[src]="pdf.obj"
(after-load-complete)="onPdfComplete($event)"
(error)="onPdfError($event)"
style="width: 100%; height: 800px;">
</pdf-viewer>
</div>
</div>
If this library is not suitable for your use case, you may try with other libraries which uses iframe or similar strategy. Refer here is a useful source worth checking it out.
I know I'm a little bit late for this post but thought of posting here might help some folks who is looking for the same thing. Hope it helps.
From ng2-pdf viewer page, it recommends your desire "angular wrapper for pdf.js", There are a ton of built in functionality Mozilla's viewer supports; such as print, download, bookmark, fullscreen, open file, zoom, search,......
If you need to display multiple PDF files simultaneously and if you don't mind using iFrames, I recommend ng2-pdfjs-viewer. https://www.npmjs.com/package/ng2-pdfjs-viewer

Resources