if i want the product image to have the following functioin,
when i upload a small image, it will not show the function,except i uploaded an enough large image,what's the smallest size of the image when installed magento with default state. thank you.
It depends on the display size of the containing element. Look at the JavaScript functions in the default included "product.js" file. You'll find this in lines 58-64:
if (this.imageDim.width <= this.containerDim.width
&& this.imageDim.height <= this.containerDim.height) {
this.trackEl.up().hide();
this.hintEl.hide();
this.containerEl.removeClassName('product-image-zoom');
return;
}
Where this.containerDim is the parent node of the image element ($(imageEl).parentNode). (I think default is a p tag with class="product-image").
Try changing the display size of the P tag to something smaller and re-initialize the Product.Zoom method with the appropriate parameters and see what happens.
If memory serves me correctly that will be 265 pixels on default theme. But nobody uses the default Magento product zoom viewer, you need to roll your own or go onto 'connect' to get something better.
Related
I would like to set the gif file in the featured image. I would like it to run when I hover over it with the mouse.
I know I should set this in functions.php file
Together with the code:
add_theme_support ('post-thumbnails');
Unfortunately, I have no idea how to do it. I create my blog and I have never done such things. Could someone help me how to do it?
Thank you for your help!
When you upload an animated GIF to WordPress, it does all of it’s resizing magic to make the various thumbnail sizes (defaults are thumbnail, medium and large, in addition to the original full). When it does this, the resized versions lose their animation.
If your theme displays featured images at any size other than full, you’ll thusly lose your GIF’s animation.
If you definitely know that you want to display the animated version, though, there’s a little trick you can use.
<?php $thumb_url = get_the_post_thumbnail_url();
$thumb_low = strtolower($thumb_url);
if (strpos($thumb_low, '.gif') === false) {
$thumb_size = 'large';
} else {
$thumb_size = 'full';
}
?>
What am I doing here is getting the URL of our featured image, then I make sure it’s all lower case letters (WordPress may do this anyway, but just to be safe), then I check to see if .gif is present in the thumbnail’s URL, and finally, if it is, I set the thumbnail size I use to ‘large’. Doing so will allow me to use the original image, which retains it’s animation.
Then, I just need to tell our call to the_post_thumbnail() to use the variable thumbnail size we set, like this:
the_post_thumbnail($thumb_size)
If you’ve ever tried to set an animated gif as a featured image in WordPress, you’ve probably discovered that you can’t.
The reason why is pretty simple. Your theme grabs a resized version of the featured image you upload. And in the case of an animated gif, that means it’s not grabbing the original gif image, and so you end up with a static image.
The way around this is pretty simple, however. You can just install a plugin that automatically sets the featured image from the first image in a post. Of course that means you will need to make the animated image the first image, but at least it’s a workaround.
There are a number of plugins that will let you automatically set your first image as the featured image. I tried two and the both worked: Autoset Featured Image and Automatic Featured Image Posts.
Something else I found was that I didn’t even need to download the gif. I could just insert it with the URL.
I want to change the default size of a textmedia video in the frontend. Right now if I upload a new video (format: vimeo), for some reason {column.dimensions.width} is 490 - is there a way to change this via typoscript? Where does that come from?
I'd be thankful for any hints!
This comes from the calculateMediaWidthsAndHeights function from the class GalleryProcessor in the system extension frontend. The width depends on some facts:
Maximum width of the media element (maxGalleryWidth)
This property is set in TypoScript. The path:
tt_content.textmedia.dataProcessing.20.maxGalleryWidth
Width for each media element. It is set inside the element. See the image below:
How many columns do you have. "Number of Columns" set to 2 in default.
The logic is like: you have a max size for your "gallery", because each textmedia element is a gallery of media elements. The function calculates how many elements you want to show in one row, caped with the max width of the element.
So you have two solution:
1) You try to adjust the TypoScript value for maxGalleryWidth and the Max Element Width
or
2) You make your own fluid template which one in case of 1 video renders it just the way you want.
fluid_styled_content is very flexible in this matter.
I'm wondering what the best approach would be for the following problem, keeping page speed in mind.
A connector syncs product data (including product images) from retail software to a PHP-based eCommerce solution like Magento.
This connector only syncs product images at a 550x550 resolution.
There is no way to alter the connector or grab larger images from the retail solution.
The person in question has a directory with higher resolution images that -for arguments sake- will match the filename from the original file with an -optional- size suffix.
How can we automatically and dynamically, on page load / image load, replace the low resolution image src with the high resolution image src?
In short: how to replace src="/path/to/low/resolution/image/shoe1.jpg with src="/path/to/high/resolution/image/shoe1-1024x1024.jpg" dynamically without writing rules specifically for that single image. As in: shoe2.jpg > shoe2-1024x1024.jpg should also work
Additionally: we do -not- have to check for missing images in the high resolution image directory. We just want to -always- replace the low resolution source url.
I was thinking about replacing the values through javascript with/without jQuery. Would that do the job?
Here's a jQuery solution:
var highRezPath = "/path/to/high/resolution/image/",
appendToFilename = "-1024x1024";
$(document).ready(function(){
$('img').each(function(ind, img){
var $img = $(img),
oSrc = $img.attr('src').split('/'),
fileName = oSrc[oSrc.length-1].replace('.', appendToFilename +'.'),
newSrc = highRezPath + fileName;
$img.attr('src', newSrc);
});
});
See it in action here (use the web inspector to see the altered src attributes)
I am using jssor slider in my site .
It works fine in every browser except in windows chrome it is showing blurry text.
I already tried setting the $HWA option to false.But still blurry text is coming up.
How to fix this issue.Thanks in advance.
It is most likely the responsive problem.
If you scale your slider larger than the original size, it may look blurry sometimes.
The way to fix it is to make the original slider bigger with larger elements and font size.
In this manner, it should look better when it scale to smaller size.
To avoid blurry text and remain slider responsive with jssor slider,
some certain change is required in file name called 'jssor.utils.js'.
In line 1045 transformValue += " perspective(2000px)";
change to
transformValue += "none";
And line 1092 elmt.style[GetTransformProperty(elmt)] = "perspective(2000px)";
change to
elmt.style[GetTransformProperty(elmt)] = "none";
I need to get the window height and width of the browser using ATK4, the lightweight php framework with jquery
The javascript to get this would be
$(window).height();
$(window).width();
As agiletoolkit integrates with jquery, i think it should be possible to get it with something like
$height=$p->js()->univ()->_selectorWindow()->height();
but this doesnt work, instead when i pass the $height variable to be used, in the HTML source i get the following .
'height':$(window).univ().height(),'width':$(window).univ().width()
and it doesnt display the element at all
I want to be able to call jqplot to set the width of a graph to the full width of the users browser on a particular page. To do this, i need to pass a parameter which is width:NNN where NNN is the number of pixels wide. As far as i know, jqplot doesnt support a parameter as a percentage so i cant say width:100%. Also, if i set a div on the page and add the graph, it also ignores the size of the div and creates a small graph 400 x 300 pixels only.
I created a plugin to use jqplot from atk4 but this is one of the issues I still need to resolve. I can pass a height and width as parameters without issue but i want it to default to the full screen size if no parameters are specified.
Can anyone suggest the right syntax for getting these values ? TIA.
what you should understand is that "$p->js()->_selectorWindow()->height();" will actually be translated to "$(window).height();" -- but you can get width of window ONLY at client side.
so, if you want to get height of the window in your code, you can do that only by using ajax request, where actual heigh is sent back from the frontend.
please, rephrase your question so that it's clear what you need height for so I can suggest best way of doing that.
example of how to get backend and frontend interlinked:
paste this in page/test.php and open up http://example/test to see in action
class page_test extends Page {
function init(){
parent::init();
$b=$this->add("Button");
$b->set("Get Width");
$b->js("click")->univ()->ajaxec($this->api->getDestinationURL(), array("width" => $this->js(true)->_selectorWindow()->width()));
$v=$this->add("View_HtmlElement")->setElement("div")->set("Click button to get width of the window");
if ($w = $_POST["width"]){
$v->js(null, $v->js()->html("Width: " . $w))->univ()->alert("Width: " . $w)->execute();
}
}
}