how to pass image size if using html::image() - kohana

how can i specify height and width of an image if i use html::image() in koahana 3. if i pass all attributes in an array it says that string expected instead of array ......please help
echo "<td class='".$class."' align='left' style='border-left:1px solid #D3D3D3'>
<a class='list_title' href='".$editBannerHref."'>".
html::image(array("src"=>"media/uploads/video_portal thumbnail".$videos[$count]->image,"alt"=>"","width"=>60,"height"=>50))."</a><br/>
<a href='".$playVideo."'>View Video</a></td>";

First parameter is file name, second attributes - http://kohanaframework.org/3.2/guide/api/HTML#image
This is the correct usage:
HTML::image("media/uploads/video_portal thumbnail".$videos[$count]->image, array("alt"=>"", "width"=>60, "height"=>50))

Related

Find if text exist inside a nested Div, if yes print out the whole string, Selenium Python

i'm very new to selenium(3.141.0) and python3, and i got a problem that couldn't figure it out.
The html looks similar to this
<div class='a'>
<div>
<p><b>ABC</b></p>
<p><b>ABC#123</b></p>
<p><b>XYZ</b></p>
<div>
</div>
I want selenium to find if # exist inside that div, (can not target the paragraph only element because sometime the text i want to extract is inside different element BUT it's always inside that <div class='a'>) If # exist => print the whole <p><b>ABC#123</b></p> (or sometime <div>ABC#123<div> )
To find an element with contained text, you must use an XPath. From what you are describing, it looks like you want the locator
//div[#class='a']//*[contains(text(),'#')]
^ a DIV with class 'a'
^ that has a descendant element that contains the text '#' within itself or a descendant
The code would look something like
for e in driver.find_elements(By.XPATH, "//div[#class='a']//*[contains(text(),'#')]"):
print(e.get_attribute('outerHTML')
and it will print all instances of <b>ABC#123</b>, <div>ABC#123</div>, or <p>ABC#123</p>, whichever exists

How can I use this UTF-8 SVG string to get <svg>?

I am using domtoimage to try to turn my html div into <svg>. The function from domtoimage returns the string:
data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="288" height="1920"> .......... </svg>
I can set this string as the src of an <img>, but the other plugin I'm using (jsPDF) cannot use that, it needs <svg>.
I figured I could strip the beginning part off and add just the svg tag to the document but this results in a really odd svg with "%0A" everywhere, which I cannot strip from the string.
If this is your code; the problem is:
you are stuffing text into the append function which only accepts DOM nodes.
Only .innerHTML converts a string to HTML
If you feed the append function a string.. it will be displayed as a string.
https://developer.mozilla.org/en-US/docs/Web/API/Element/append
Note the documentation: DOMString objects are inserted as equivalent Text nodes.
Solution is to create an SVG DOM element
let svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svgElem.innerHTML = mySvg;
$('body').append(svgElem);

embedded spaces in a computed field don't show

I have some code in a computed field where I want to embed some spaces between two values:
var rtn:String = doc.getItemValue("RefNo")[0] + " " + doc.getItemValue("Company")[0];
the computed field Display Type = text and the content type is String but the display strips out all the extra spaces. Is there a function like insertSpaces(5) that would insert 5 hard spaces?
Figured it out insert "&#160" + "&#160" and display as HTML. fairly simple but really ackward.
It will print them out as whitespace in HTML output. It will not be rendered.
You can add instead (5 times in your case).
An alternative way is to set style="white-space: pre;" (works IE8+ and other browsers)

Watir-webdriver:How to read tooltip text

I am writing a script to set verify tool-tip for label control. I am using
$browser.label(:text,"Help").hover
$browser.text.include?("Hint Text").should == true
When I execute this, tool tip is displayed on browser, but I am not able to assert the tool-tip.
Is there any other way to do this?
You can check the title attribute of an element using the title method.
Assuming that the element is:
<label title="Hint Text">Help</label>
You can get the title attribute value:
$browser.label(:text => "Help").title
#=> "Hint Text"
Or as a validation in a test:
$browser.label(:text => "Help").title.should eq("Hint Text")
Note that you do not need to hover over the element to check its title attribute.

changing the font color in a computed field using javascript

How to change the font color of Hello alone in "Hello World" using javascript/some other method?
I tried the following code,
var s= session.getCommonUserName()
s.fontcolor("green")
"Hello"+" "+ s.toUpperCase()
where i tried to change just the color of the username alone. But it failed.
I wouldn't bother to send down unformatted HTML to the client and then let the client do the JavaScript work. You create a computed field and give it the data type HTML (that keeps HTML you create intact) and use SSJS. So no JS needs to execute at the client side:
var cu = session.getCommonUserName();
return "Hello"+" <span style=\"color : green\">"+ cu.toUpperCase()+"</span>";
Don't forget to cross your t, dot your i and finish a statement with a semicolon :-)
If you want to do it with client java script, then you must do something like this:
dojo.style("html_element_id", "color", "green");
So in your case you can have have something like:
<p><span id="span1">Hello</span> World.</p>
Or you can do it directly if you don't need to change it with CJS:
<p><span style="color:green">Hello</span> World</p>
one way to do it is to wrap your 'hello' in a html span and then change the color of that span.
<span id='myspan'>hello</span> world
javascript code:
document.getElementById('myspan').style.color='green';
Went old school on this one...
Say you want to put your formatted text in a div
<div id="test">
</div>
Then you need the following javascript to do so:
div = document.getElementById("test");
hello = document.createElement("span");
hello.innerHTML = "Hello"
hello.style.color = "green";
div.appendChild(hello);
div.appendChild(document.createTextNode(" world!"));

Resources