New param required to display Image for Mobile/Tablet.

More
12 years 7 months ago #38693 by Rooney

brandonking wrote: @ggppdk and Rooney
About mobile detect, I didn't know that FC already had this function.... :)
So maybe it's better to leave as plugin installation.

Sorry. This is a misunderstanding. I am using FC and I am using an own mobile detect file. I meant that if FC would have an in-built mobile detect then it could be conflicting with my or other solutions and that a plugin would give the choice to use a FC version or not...
Rooney

Joomla! 3.9.24 and FC 3.3.9

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

More
12 years 7 months ago #38694 by ggppdk
Hello, Rooney

the suggested mobile detection library seems to be very common/popular, i have added locally (into a new helper function so that the detection object is created only once) and testing this ...

About your doubts/thoughts:

-- it will not conflict with your mobile detection,
it will just add a small overhead of calling these twice
a. once inside a flexicontent helper function to be used everywhere inside FLEXIcontent (FC fields / FC templates / etc) and
b. once in you custom code/joomla template ...


-- Of course if one method detects mobile but other method thinks that it is desktop, then you would get:

e.g. a joomla template in desktop mode but the FLEXIcontent fields or FLEXIcontent template be in "mobile" mode

but this is unlikely to happen, if it happens one of the 2 methods/libraries is not optimally implemented

Any thoughts
e.g. does J3.x provide a built-in method of detecting mobile ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
12 years 7 months ago #38695 by brandonking
Sorry Rooney, I misunderstood. :)

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

More
12 years 7 months ago #38696 by ggppdk
Hello,
as i said above i would rather use a 3rd party maintained library, rather than maintain our own detection

but the experimental built-in method of FLEXIcontent also has code to detect screen size (not window that is screen size) and thus set the isMobile FLAG based on screen resolution AND/OR browser reported type

any thoughts ?

e.g.
use this popular mobile Detection library
but also keep our screen resolution detection code ???


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
12 years 7 months ago #38698 by brandonking
Sorry, I thought you were asking to Rooney.. :D
Well, I think only one will be enough to have mobile detect but I guess the one I suggested will have more options coz we can even get device name and so on. Also they will keep update for new device as well.
Having two will just make heavier... A little though. :D

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

More
12 years 7 months ago #38699 by ggppdk
Yes,
just screen resolution code is not present in mobile detector and is independent of client it is JS-based and will work without need of maintenance,

the benefit is that you want to know if user is mobile client aka using finger , etc

but also the screen resolution maybe useful for deciding layout , even when having a responsive layout


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

More
12 years 7 months ago #38700 by Rooney
I have to ask my web designer Angie Radtke which mobile_detect.php she is using, but the contents below.
Code:
<?php /** * Mobile Detect * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ class Mobile_Detect { protected $accept; protected $userAgent; protected $isMobile = false; protected $isAndroid = null; protected $isAndroidtablet = null; protected $isIphone = null; protected $isIpad = null; protected $isBlackberry = null; protected $isBlackberrytablet = null; protected $isOpera = null; protected $isPalm = null; protected $isWindows = null; protected $isWindowsphone = null; protected $isGeneric = null; protected $devices = array( "android" => "android.*mobile", "androidtablet" => "android(?!.*mobile)", "blackberry" => "blackberry", "blackberrytablet" => "rim tablet os", "iphone" => "(iphone|ipod)", "ipad" => "(ipad)", "palm" => "(avantgo|blazer|elaine|hiptop|palm|plucker|xiino)", "windows" => "windows ce; (iemobile|ppc|smartphone)", "windowsphone" => "windows phone os", "generic" => "(kindle|mobile|mmp|midp|pocket|psp|symbian|smartphone|treo|up.browser|up.link|vodafone|wap|opera mini)" ); public function __construct() { $this->userAgent = $_SERVER['HTTP_USER_AGENT']; $this->accept = $_SERVER['HTTP_ACCEPT']; if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) { $this->isMobile = true; } elseif (strpos($this->accept, 'text/vnd.wap.wml') > 0 || strpos($this->accept, 'application/vnd.wap.xhtml+xml') > 0) { $this->isMobile = true; } else { foreach ($this->devices as $device => $regexp) { if ($this->isDevice($device)) { $this->isMobile = true; } } } } /** * Overloads isAndroid() | isAndroidtablet() | isIphone() | isIpad() | isBlackberry() | isBlackberrytablet() | isPalm() | isWindowsphone() | isWindows() | isGeneric() through isDevice() * * @param string $name * @param array $arguments * @return bool */ public function __call($name, $arguments) { $device = substr($name, 2); if ($name == "is" . ucfirst($device) && array_key_exists(strtolower($device), $this->devices)) { return $this->isDevice($device); } else { trigger_error("Method $name not defined", E_USER_WARNING); } } /** * Returns true if any type of mobile device detected, including special ones * @return bool */ public function isMobile() { return $this->isMobile; } protected function isDevice($device) { $var = "is" . ucfirst($device); $return = $this->$var === null ? (bool) preg_match("/" . $this->devices[strtolower($device)] . "/i", $this->userAgent) : $this->$var; if ($device != 'generic' && $return == true) { $this->isGeneric = false; } return $return; } }

Rooney

Joomla! 3.9.24 and FC 3.3.9

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

More
12 years 7 months ago #38701 by brandonking
I have found that mobile detect you use created by same developer.

Your version is r8 by serbanghita on Mar 13, 2012
code.google.com/p/php-mobile-detect/sour...obile_Detect.php?r=8

Or, you can get Latest one from below.
mobiledetect.net/

And The one that I am suggesting Mobile detect plugin for joomla is created by yagendoo Media based on above one.

They mentioned as below.

Credits

The plug-in is based on the (MIT) code library of Serban Ghita, which is also available free of charge and forms the core of the plug-in. Thank you for your great work, Serban!


You can check it below link..
www.yagendoo.com/en/blog/free-mobile-det...ugin-for-joomla.html

Hope we are in the same boat!! :D

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

More
12 years 7 months ago #38703 by brandonking

ggppdk wrote: Hello,
thanks for suggestions / and code contribution

-- About system cache plugin i have not looked into a way to bypass it, maybe it is possible:

this plugin is great for speed and FLEXIcontent works smoothly with it (maybe you will not needed it once we fix performance of universal content module (soon)),
-- your options are
1. check if it is possible to do some check inside template index.php (does system plugin allow execution to reach this file i think yes , i have not checked ...)
2. hack the joomla cache plugin to include the mobile detect code ...
3. duplicate it and make a custom version of it ???


Just one thing about your changes , please read below:

i think one of your changes not best approach ...

-- You have added 2 more OPTIONS for parameters "popuptype", so far this is good

... but you added also a 3rd option "9" for autoselecting these when mobile client is detected, this not best approach, because you limit your choices to just 2 options ...

It is better to add 1 more LIST parameter called "popuptype_mobile" which will have the same OPTIONS as "popuptype" but also one more:

Code:
<option value="">Same as non-Mobile</option>
(notice that value is empty we will use strlen below)
so:
Code:
$popuptype = $field->parameters->get( 'popuptype', 1 ) ;
add:
Code:
$popuptype_mobile = $field->parameters->get( 'popuptype_mobile', '' ) ; if ($detect && strlen($popuptype_mobile)) $popuptype = $popuptype_mobile;

and then in your code replace:
Code:
!$detect && $popuptype == 9
with:
Code:
$usepopup && $popuptype == 7
and
Code:
$detect && $popuptype == 9
with:
Code:
$usepopup && $popuptype == 8

and now you can use ANY js image library for mobile

i will commit these changes ... in next commit

when you update to latest FLEXIcontent, just edit image field and set both 'popuptype' and 'popuptype_mobile'



Yeap, followed as you mentioned and just works like a charm!!
Thank you

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

More
12 years 7 months ago #38708 by ggppdk
Hello,

I tested the time required to execute the mobile detector and of course time is minimal e.g. on my dev pc is 0.006 seconds (that is regardless of how many times you call it because after 1st call the results are cached ...,
which is mostly some regular expression tests executed on rather small string,

consider that system plugin executed regular expressions on the full page text may take up to e.g. 1 second (e.g. jqueryeasy plugin is a great plugin but it is very costly ... e.g. can take up to 1 second on loaded server)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save